From 59083edbc6207f43836ea23d4236c79bc526bf87 Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Sat, 3 Dec 2011 21:47:37 +1300 Subject: [PATCH] Tidy up the forking logic to more inline with my style. --- bin/mythtv-status | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bin/mythtv-status b/bin/mythtv-status index 5fe32f9..6904325 100755 --- a/bin/mythtv-status +++ b/bin/mythtv-status @@ -1025,16 +1025,21 @@ sub xml_fetch { local $SIG{ALRM} = sub { die "alarm\n" }; alarm(30); $content_type = ; - while (my $line = ) { - $status .= $line; + while () { + $status .= $_; } alarm(0); }; # The child didn't get back to us in time, kill them off. if ($@) { - kill 15, $pid + my $result; + do { + kill 9, $pid; + $result = waitpid($pid, WNOHANG); + } while $result > 0; } + $| = 0; return ($content_type, $status); } else { @@ -1061,6 +1066,7 @@ sub xml_fetch { sub pipe_from_fork ($) { my $parent = shift; + $SIG{CHLD} = 'IGNORE'; pipe $parent, my $child or die; my $pid = fork(); die "fork() failed: $!" unless defined $pid; -- 2.30.2