Unix Programming - How to know PID from perl program

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > December 2005 > How to know PID from perl program





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author How to know PID from perl program
saurabhlamgora@gmail.com

2005-12-22, 7:50 am

I want to know PID of external program from PERL script.

Victor Wagner

2005-12-22, 7:50 am

saurabhlamgora@gmail.com wrote:
: I want to know PID of external program from PERL script.

Which external program?

One you've spawned using open PROGRAM,"|program" or completely
unrelated?


If first, you can do following

$pid = open(PROGRAM,"|-")
die $! if (!defined($pid));
exec program if $pid == 0;

Now, you have program connected to your filehandle and its pid in the
variable $pid.

If second, you should look to Proc::ProcessTable module on CPAN.




--
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com