Home: Need a Custom or Prewritten Perl Program?: I need a program that...:
PID



cbwery2
Deleted

Sep 18, 2000, 5:34 AM


Views: 2228
PID

hi,

Is there a way to know the PID of a
son process.

I run a small perl program, where I have
to lunch a program made in C.

After a while I have to kill the
process and start it again.

So I need to find the PID. I know I can
find a Parent PID from a process (getppid)
but I need "the Son PID"

thanks any help.



------------------


gekofish
Deleted

Sep 18, 2000, 7:13 PM


Views: 2228
Re: PID

Actually you can call "ps" in your code to list the PIDs of sons of your parent PID and then retrieve that using grep etc.

------------------
If you ever need a custom perl/java script or a java applet done for you, please drop me a line to get a quote


Kanji
User / Moderator

Sep 18, 2000, 8:46 PM


Views: 2228
Re: PID

Depends how you invoke the child. If you're using fork() it's nice and easy ...
<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

if ( $cpid = fork ) {
print "I'm the parent. My pid is $$, and my child is $cpid";
} else {
print "I'm the child. My pid is $$, and my parent is ", getppid;
}</pre><HR></BLOCKQUOTE>