Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!att!dptg!pegasus!mpl From: mpl@pegasus.ATT.COM (Michael P. Lindner) Newsgroups: comp.unix.questions Subject: Re: Get process name w/o using argv[0] in C function? Message-ID: <4944@pegasus.ATT.COM> Date: 31 Jul 90 19:34:42 GMT References: <9220003@hpldsla.sid.hp.com> Reply-To: mpl@pegasus.ATT.COM (Michael P. Lindner) Organization: AT&T Bell Labs NJ USA Lines: 22 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? deleted >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! deleted >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. deleted >Manoj. No. There is no way to do this. I do not understand why you would rather write code to scan through the proc table (which, incidentally, will require a setuid or setgid for your program and introduce all sorts of security risks) than use a global. If you know your architecture, you can do a stack trace on your process from inside to get to argv, but that is non-portable and ugly, too (although I have a routine which does it - I like ugly things, sometimes :^) My recommendation: BREAK DOWN AND USE A GLOBAL. Mike Lindner attmail!mplindner