What is the proper way to kill on Windows a process which has been started with a forked Windows call, i.e.
system(1,...)? I'm trying the following:
my $pid=system(1,"my_prog.bat");
...
if(kill(9,$pid)) {
print "Killing $pid was not successful\n" if kill(0,$pid);
} else {
print "Signal did not reach process $pid\n";
}
I always get "Killing ... was not successful".
I know that the process is still running at the time the first kill is issued. The purpose of the second kill (with 0 zero) is to ensure that the process really got killed. If it was, kill should return 0 (no such process), but it returns non-zero, showing that the process still lives. Indeed, I can see from the output that the "killed" process happily runs to the end.
--
Ronald Fischer <ynnor@mm.st>
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.