新手求助:无法杀掉子进程

jkiluy111 2015-12-03 09:02:04
逻辑是这样的:启动一个线程,然后这个线程去调用外部命令、脚本什么的。由于外部命令很慢,我主线程的逻辑会把这个线程杀掉。当然那个子进程也得干掉。
->额...需要有这种逻辑,勿吐槽..

测试的子进程逻辑很简单 :while(1){}



使过 perl的system、fork+exec win32api的Win32::Process::Create 来启动进程


然后试过 perl的kill Win32的 ->Kill()
效果都是:俺的perl进程退出了....调用的子进程就变成孤儿进程被系统接管...不应该啊...我在退出perl进程前已经先kill了那个子进程......




被折腾的生活不能自理了....
...全文
204 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
jkiluy111 2015-12-07
  • 打赏
  • 举报
回复
已经找到了...原来perl跟C不一样... The outcome of kill on a pseudo-process is unpredictable and it should not be used except under dire circumstances, because the operating system may not guarantee integrity of the process resources when a running thread is terminated. 线程kill不掉也是 The thread signalling capability provided by this module does not actually send signals via the OS. It emulates signals at the Perl-level such that signal handlers are called in the appropriate thread. Correspondingly, sending a signal to a thread does not disrupt the operation the thread is currently working on: The signal will be acted upon after the current operation has completed.
jkiluy111 2015-12-03
  • 打赏
  • 举报
回复
perl用得是 ActivePerl 5.16.2 Build 1602 (64-bit) 希望不是这玩意的问题...几乎没有换得可能

37,719

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • IT.BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧