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


In reply to Re: Using Proc::Background and Win32 by mmartin
in thread Using Proc::Background and Win32 by mmartin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.