On Tue, 2 Mar 2004, Harry Putnam wrote: > > What is the handy way to record the pid of $some_process in this > fake code? > > $some_process = 'tcpdump -v -ieth0 >file') > system("$some_process") or die "Can't start $some_process: $!"; > > print "Pid is $pid\n"; > > The process is started by a more elaborate perl script at bootup. > and restarted every four hours from syslog. Code above is way simplified. > >
I don't think you can get the PID when using the system() function. Also, I am fairly sure that system() does not return control to your Perl script until the function it invokes finishes. Would something like: use Errno qw(EAGIN); ... $someprocess=... FORK: { if ($pid=fork) { print "PID is $pid\n"; } elsif (defined $pid) { exec $someprocess; } elsif ($!=EAGIN) { sleep 5; #wait five seconds redo FORK; #then try again } else { die "Cannot fork to run $someprocess $!"; } } -- Maranatha! John McKown -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>