Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!leah!itsgw!steinmetz!crdgw1!uunet!vsi!friedl From: friedl@vsi.COM (Stephen J. Friedl) Newsgroups: comp.lang.c Subject: Re: Re^2: Functions pointers and stuff. Summary: /proc to the rescue! Message-ID: <1079@vsi.COM> Date: 31 Mar 89 03:08:35 GMT References: <1715@leah.Albany.Edu> <3182@goofy.megatest.UUCP> <301@oha.UUCP> <302@oha.UUCP> Organization: V-Systems, Inc. -- Santa Ana, CA Lines: 31 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@oha.UUCP>, tony@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@vsi.com / {attmail, uunet, etc}!vsi!friedl "I do everything in software, even DMA" - Gary W. Keefe (garyk@telxon)