我可以告诉perl在运行时超过某个时间限制时发出警报/信号而不退出吗?

Que*_*Guy 4 perl timeout runtime

我正在设置一个警报类型调用,让我知道我的程序运行时间是否超过10分钟我希望程序在发送警报或信号后继续运行.我以为我可以执行以下代码,但程序会在运行时间达到十分钟时停止.

eval{
     local $SIG{ALRM} = sub { die "alarm\n"; };
     alarm (600);
     --code---
     alarm 0;
};
if($@){
     print "\Its been ten minutes\n";
}
Run Code Online (Sandbox Code Playgroud)

我希望应用程序通知我但继续运行.

Сух*_*й27 6

不要因为闹钟而死,你会没事的,

local $SIG{ALRM} = sub { print "Its been ten minutes\n"; };
Run Code Online (Sandbox Code Playgroud)