Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!ficc!peter From: peter@ficc.ferranti.com (Peter da Silva) Newsgroups: comp.unix.questions Subject: Re: Get process name w/o using argv[0] in C function? Message-ID: <1O+4YYC@xds13.ferranti.com> Date: 1 Aug 90 18:46:14 GMT References: <9220003@hpldsla.sid.hp.com> Reply-To: peter@ficc.ferranti.com (Peter da Silva) Organization: Xenix Support, FICC Lines: 14 In article <9220003@hpldsla.sid.hp.com> manoj@hpldsla.sid.hp.com (Manoj Joshi) writes: > Is there a way to get the name of a process anywhere inside the source? > 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! Why not? This is guaranteed global per-process static data. There is no reason not to use a global. > 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. All this to avoid using a global? Especially considering that this will not work unless you're running as root! -- Peter da Silva. `-_-' +1 713 274 5180. 'U`