Get process name w/o using argv[0] in C function?

Guy Harris guy at auspex.auspex.com
Wed Aug 1 04:17:37 AEST 1990


>Also, I do not think I want to use a global and initialize it to
>argv[0] in body of main(), because I do not use globals!

Perhaps you should start doing so.  The only portable alternatives are
1) use a global or 2) pass argv[0] all the way down.

>I know that getpid() and getppid() get me the process id and parent's
>process id.

In effect, the process ID *is* a global, although in most UNIX
implementations it's not accessible directly from user code.  So if
you're using "getpid()", you're already using a global; it just happens
to be hidden inside a routine (a routine in the kernel, in most
implementations).  If globals really offend you, you might want to hide
the global in question inside a function.... 



More information about the Comp.unix.questions mailing list