It's not paramount that I use the Proc::Background Module, but I do need to run the command in
in the background and have the ability to check on if it's still running or not...
So I tried this way which seemed to execute my script in the background without ANY problems at
all. But when I attempt to check on it's progress I get the same result no matter if it's running
or not.
my $pid = system 1, "bg_script.pl $ARG1 \"$ARG2\" $ARG3 $ARG4 $ARG5";
print "\$pid == '$pid'\n";
my $still_running = kill 0, $pid;
print "BEFORE SLEEP: \$still_running == '$still_running'\n\n";
sleep 10;
$still_running = kill 0, $pid;
print "AFTER SLEEP: \$still_running == '$still_running'\n\n";
The variable $still_running returns "1" on both executions...
Am I not doing the "kill" command correctly? According to Perldoc that is in the correct format, which is:
http://perldoc.perl.org/5.14.2/functions/kill.html
kill SIGNAL, LIST
Where LIST is the processes to check and SIGNAL, when zero, does nothing but check if it's alive still. But
when I run the check:
$still_running = kill 0, $pid;
It returns 1 no matter if it's running or not, I can see that the bg_script.pl is done running after it does
the 10 second sleep. So I'm not sure why it's returning "1" both times?
If I can figure this one out then I can stop killing myself over the Proc::Background Command...
I was also looking at the
Win32::Process page, but I saw that on the
Proc::Background page it
actually uses the Win32::Process if you PC is Windows. So I guess it wouldn't help to implicitly use that
Module? Does that make sense?
http://search.cpan.org/~bzajac/Proc-Background-1.10/lib/Proc/Background.pm
http://search.cpan.org/~jdb/Win32-Process-0.14/Process.pm
Thanks Again for the replies fellas, much appreciated!
Thanks,
Matt