|Think about Loose Coupling|
Exec() and getting system PIDby r.joseph (Hermit)
|on Jan 14, 2002 at 02:37 UTC||Need Help??|
r.joseph has asked for the wisdom of the Perl Monks concerning the following question:
Hello all - this is probably a easy question to answer, but I cannot seem to figure it out.
I need to launch a system process by a perl program (in my case, the program is called "root-tail") and get the Process ID for that program back so that I can save it to a file. Now, I am doing the fork()/exec() method:
Now, there are probably about ten arguments to "root-tail", and have them all just strung together in the exec() call, like above. However, when I save the PID to a file, and then go back and compare this PID with the PID of the process that is ACTUALLY RUNNING (via a call to 'ps'), the actual process id is always one higher: if my file that I saved to says 150, the actual pid is 151.
Does anyone know why this would happen? The perldoc's say that if there is a list of args to exec(), the shell will not be used at all, so why is there more than one process running, creating the one-up PID for my actual process?
Thanks for the help!
r. j o s e p h
"Violence is a last resort of the incompetent" - Salvor Hardin, Foundation by Issac Asimov