my ($boots) = 0;
local ($|) = 1;
for (;;) {
- if (waitpid ($pid, WNOHANG) == 0) {
+ if (waitpid ($pid, WNOHANG) != 0) {
# Subprocess died. Pass through any remaining data.
print $buf while sysread ($in, $buf, 4096) > 0;
last;
# Read and print out pipe data.
my ($len) = length ($buf);
- last if sysread ($in, $buf, 4096, $len) <= 0;
+ waitpid ($pid, 0), last
+ if sysread ($in, $buf, 4096, $len) <= 0;
print substr ($buf, $len);
# Remove full lines from $buf and scan them for keywords.
}
}
}
+ } else {
+ waitpid ($pid, 0);
}
- waitpid ($pid, 0);
alarm (0);
&$cleanup ();