CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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

 



cbwery2
Deleted

Sep 18, 2000, 5:34 AM

Post #1 of 3 (861 views)
PID Can't Post

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

Post #2 of 3 (861 views)
Re: PID [In reply to] Can't Post

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

Post #3 of 3 (861 views)
Re: PID [In reply to] Can't Post

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>

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives