rovf has asked for the wisdom of the Perl Monks concerning the following question:
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:
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.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"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Killing on Windows
by ikegami (Patriarch) on Sep 09, 2009 at 14:44 UTC | |
by rovf (Priest) on Sep 10, 2009 at 08:00 UTC | |
by BrowserUk (Patriarch) on Sep 10, 2009 at 10:28 UTC | |
by rovf (Priest) on Sep 10, 2009 at 10:52 UTC | |
by BrowserUk (Patriarch) on Sep 10, 2009 at 11:03 UTC | |
|