Task-Server mit SIGALRM sofort aufwecken können
[kivitendo-erp.git] / scripts / task_server.pl
index 5854a51..1ac7e31 100755 (executable)
@@ -123,7 +123,16 @@ sub gd_run {
     }
 
     my $seconds = 60 - (localtime)[0];
-    sleep($seconds < 30 ? $seconds + 60 : $seconds);
+    if (!eval {
+      local $SIG{'ALRM'} = sub {
+        $::lxdebug->message(0, "Got woken up by SIGALRM") if $lx_office_conf{task_server}->{debug};
+        die "Alarm!\n"
+      };
+      sleep($seconds < 30 ? $seconds + 60 : $seconds);
+      1;
+    }) {
+      die $@ unless $@ eq "Alarm!\n";
+    }
   }
 }