[comp.unix.questions] process name from process id

kannan@cerc.wvu.wvnet.edu (R. Kannan) (06/22/89)

The main objective is to get the program file name that resulted
in the process.

I have the pid for a process. I want to find out the name of
the program file that resulted in that process.


some_unknown_function ( getpid () ) => should return the name of the program
file that resulted int he calling process.

Thank you.

I want soemthing better than "ps | grep getpid ()" route. Direct callable
function. 

--kannan

mhoffman@infocenter.UUCP (Mike Hoffman) (07/01/89)

in article <157@cerc.wvu.wvnet.edu.edu>, kannan@cerc.wvu.wvnet.edu (R. Kannan) says:
< Xref: gould comp.unix.questions:12137 comp.unix.wizards:14115
< 
< The main objective is to get the program file name that resulted
< in the process.
< 
< some_unknown_function ( getpid () ) => should return the name of the program
< file that resulted int he calling process.

Forgive me if I'm being dense, but isn't argv[0] the name of the called
program??

If you use getpid() you must be looking for the identity of the program
currently running, not some arbitrary process, so why not just set
program_name = argv[0] ??

                    Michael J. Hoffman          
                    Manufacturing Engineering  
                    Encore Computer Corporation
UUCP: {uunet,codas!novavax,sun,pur-ee}!gould!mhoffman        Melbourne, Fl 32935
"My opinions are my own and are not to be employed with those of my confuser."