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。
在此先感謝。