Strings as function names (again)

Wolfram Roesler wolfram at akela.informatik.rwth-aachen.de
Wed Feb 13 23:59:10 AEST 1991


>gwyn at smoke.brl.mil (Doug Gwyn) writes:

>>One is that you have to tell it a path to the executable file, and
>>that is not in general available for the currently-executing process.

>Sure? How about argv[0] ?

Hello you pyromanics, stop flaming me for this line. I am sorry if I
insulted a guru but if I want to contradict to anybody I do it regardless
if he's a guru, the chinese emperor or anybody else. However, if the guru
was seriously insulted by my comment I recommend psychotherapy.

I did not say "argv[0] contains the executable path of the running prg".
All I meant by my comment was that argv[0] can be used to obtain it.
Not always, I know, not necessarily portably, I know too. I might be new
to comp.lang.c but I am not new to C. And I hadnt yet read the FAQ (thanks
for mailing me, whoever did).
Using execl or some other syscall to make argv[0] be completely different
from the bin path is very rarely used (calling login shells is the only
example that comes to my mind). It's very easy to scan the $PATH and search
for the executable file. This does not work always, I know. It will work
most of the time, it will work always when a program is called in the
regular fashion. So, (daring to contradict guru doug again,) it's not
true that the executable path is not in general available to a process.
It is available in general, since the general case is that a program
is called with argv[0] containing at least a part of the executable path, and
the rest can be obtained from $PATH.

Once again, stop flaming me, you're wasting your time. And gurus, tell
your disciples not to do so. And guru disciples, think if it's not a better
thing to pray to Jesus of Jahwe or Buddha or anyone else.



More information about the Comp.lang.c mailing list