Path: utzoo!attcan!uunet!cs.utexas.edu!know!zaphod.mps.ohio-state.edu!sdd.hp.com!hplabs!hpcc01!hpcea!hpldsla!manoj From: manoj@hpldsla.sid.hp.com (Manoj Joshi) Newsgroups: comp.unix.questions Subject: Get process name w/o using argv[0] in C function? Message-ID: <9220003@hpldsla.sid.hp.com> Date: 31 Jul 90 00:48:47 GMT Organization: HP Scientific Instruments Division - Palo Alto, CA Lines: 16 Is there a way to get the name of a process anywhere inside the source? By name, I mean argv[0]. As an alternative, I can pass argv[0] as an extra parameter from main() to every function in the program, but I think it is inefficient. 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! I know that getpid() and getppid() get me the process id and parent's process id. From this I can scan thru the proc table in proc.h, and get the process name as a string. But this may be non-portable C. Note that __FILE__ does not solve my problem, because it does not return the name of the final executable, but only the current source file. Anyone find out how to do this? Manoj.