disorder-ondemand.in: Guard against `$PID' getting lost halfway through.
[disorder-toys] / disorder-ondemand.in
index d9429bb..98e39c2 100755 (executable)
@@ -49,7 +49,7 @@ $SIG{CHLD} = sub {
 };
 
 $SIG{TERM} = $SIG{INT} = sub {
-  kill "TERM", $PID if defined $PID;
+  eval { my $pid = $PID; kill "TERM", $pid if defined $pid; };
   exit 0;
 };
 
@@ -130,7 +130,7 @@ sub watch_status () {
       }
 
       @lines = split /\n/, $buffer, -1;
-      $buffer = pop @lines;
+      $buffer = pop(@lines) // "";
     }
 
     for my $line (@lines) {