1
我在windows上使用perl v14。我有2个简单文件:发信号给perl进程从一个独立的perl进程触发代码处理器
$SIG{'INT'} = sub {
print "got SIGINT\n";
#some useful code to be executed
#on reception of signal
};
$SIG{'ALRM'} = sub {
print "got SIGALRM\n";
};
print "my pid: ",$$,"\n";
while(1)
{
print "part 1\n";
sleep(3);
print "part 2\n\n";
sleep(3);
}
上面的文件启动并等待被给予其PID。 第二个文件使用其pid(手动设置)简单地杀死第一个perl进程。
$pid = xxxx; #this is the manually entered pid for I process
print "will attempt to kill process: $pid\n";
kill INT, $pid;
我跑第一perl脚本,然后按Ctrl-C是什么,处理程序工作正常,但使用第二个文件,我不能得到相同的结果。我也尝试过其他信号,如ALRM,HUP,TERM,FPE,但没有成功。我想要做的就是在信号处理程序中执行代码。
我找到了一种叫INT2的信号for win32。
在此先感谢。