Skip to content

Commit

Permalink
log the time and wait for zombies
Browse files Browse the repository at this point in the history
  • Loading branch information
lukec committed Jul 30, 2009
1 parent b121039 commit d679b7a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion bin/read-arduino
Expand Up @@ -3,6 +3,7 @@ use strict;
use warnings;
use Fatal qw/open/;
use FindBin;
use POSIX ":sys_wait_h";

my $arduino_file = '/dev/ttyUSB0';

Expand All @@ -11,7 +12,8 @@ while (my $line = <$fh>) {
chomp $line;
next if $line =~ m/^\s*$/;
my ($command, @args) = split m/\s+/, $line;
print "Received command: $command args: (@args)\n";
my $now = localtime;
print "$now: Received command: $command args: (@args)\n";

my $script_dir = "$FindBin::Bin/../hooks/${command}.d";
my @scripts = glob("$script_dir/*");
Expand All @@ -24,6 +26,11 @@ while (my $line = <$fh>) {
}
}
}
print "Cleaning up zombies\n";
my $kid;
do {
$kid = waitpid(-1, WNOHANG);
} while $kid > 0;
}

exit;
Expand Down

0 comments on commit d679b7a

Please sign in to comment.