我需要使用特定的exitcode吗?
Win32::Process::Create( $ProcessObj,"C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe","firefox -no-remote -P $prof_name",NORMAL_PRIORITY_CLASS,".")|| die ErrorReport(); $ProcessObj->kill(0);
这样就可以杀死它,但不是轻微的,它会导致Firefox配置文件出现问题.
解决方法
除了Window的taskkill之外的简短常用方法是有力的.感谢
mob和
melpomene.
Win32::Process
文档没有说明Kill或KillProcess所做的方法,但他们似乎对此非常直率. Windows确实提供了如何终止进程的渐变,例如参见graceful termination via winapi上的这篇文章,即使它没有UNIX的信号.然而,这显然没有被模块使用,也没有被杀死(见最后).
Windows自己的taskkill应该很好地要求进程终止.通过运行taskkill /?查询标志.在您系统的控制台中.这是taskkill on MS technet
的文档.例如,这将通过其$pid及其子项终止进程
my $pid = $ProcessObj->GetProcessID(); system("taskkill /t /pid $pid");
如果方法GetProcessID()未返回实际ID,请参阅下面的链接以了解其他方法.
我现在无法在Windows上测试. this post
第二部分有更多相关细节.
在Windows上,Perl的杀戮显然是有力的.从perlport
…
kill($sig,$pid)
terminates the process identified by$pid
,and makes it exit immediately with exit status$sig
.
我相信,exitcode只会告诉处理向系统报告的内容.