Short Usual methods other than Window's taskkill
are forceful. Thanks to mob and melpomene.
The Win32::Process documentation doesn't say what the methods Kill
or KillProcess
do, but they seem pretty blunt about it. Windows does provide a gradation in how to terminate a process, see for example this post on graceful termination via winapi, even as it does not have UNIX's signals. However, this is apparently not utilized by the module nor by kill
(see end).
The Windows's own taskkill
should nicely ask the process to terminate. Query it for flags, by running taskkill /?
in a console on your system. Here is documentation for taskkill on MS technet. For example, this terminates the process by its $pid
, along with its children
my $pid = $ProcessObj->GetProcessID();
system("taskkill /t /pid $pid");
If the method GetProcessID()
doesn't return the real ID, see the link below for other ways.
I can't test on Windows right now. There's a bit more related detail in this post, second part.
Perl's kill
is apparently forceful on Windows. From perlport
... kill($sig, $pid)
terminates the process identified by $pid
, and makes it exit immediately with exit status $sig
.
Thanks to melpomene for comment and documentation link.
The exitcode
, I believe, only tells to process what to report to the system as its exit.