Re^2: Functions pointers and stuff.

Stephen J. Friedl friedl at vsi.COM
Fri Mar 31 13:08:35 AEST 1989


Henry Spencer wrote:
>
> The problem here is the assumption that argv[0] is a full pathname for
> the program.  In general it's not, and finding the binary is not a
> trivial exercise.

In article <302 at oha.UUCP>, tony at oha.UUCP (Tony Olekshy) writes:
> Henry is, of course, completely correct, so two things are possible:
> 
>  b) Deliberately make the name of the binary known during the installation
>     process, and check the consistency of this information at run-time.
>     This is an alternative which meets the needs set out in the original
>     posting.

First, ksh provides the full pathname in $_, but this of course can
be fooled.

When Sys V Rel 4 comes out, you'll be able to get a file descriptor
to your own executable with an ioctl on a /proc/##### file, where
##### is your pid.  If there is a symbol table there you will be able
to reliably map a function name to an address at runtime.

/proc is really cool.

     Steve

-- 
Stephen J. Friedl / V-Systems, Inc. / Santa Ana, CA / +1 714 545 6442 
3B2-kind-of-guy   / friedl at vsi.com  / {attmail, uunet, etc}!vsi!friedl

"I do everything in software, even DMA" - Gary W. Keefe (garyk at telxon)



More information about the Comp.lang.c mailing list