子进程超时又父进程强制结束,但是子进程在规定的时间内完成了。父进程如何结束?
以下是我的代码:
isOvertime()是超时判断函数
use warnings;use strict;my($pid);$| = 1;if($pid=fork()){ print("$pid \n"); sleep(1); while(1) { if (isOvertime()) { kill('STOP',$pid); print("Sorry,you are overtime .\n"); exit(); } else { if(wait()) { print("OK , now i can go .\n"); exit(); } } }}elsif(defined($pid)){ sleep(30); print("i am ok! \n"); exit(); }else{ print("error \n"); }