From: Colin Patrick McCabe Date: Sat, 3 Apr 2010 20:58:45 +0000 (-0700) Subject: superrip: check exit status of children X-Git-Url: http://club.cc.cmu.edu/~cmccabe/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=32830ca1bcd155b9458d30f67e2bc4b5d9324e45;p=cmccabe-bin superrip: check exit status of children Always check the exit status of children to make sure there were no errors. Also, when handling an exception in the child, print out what it is before exiting. --- diff --git a/superrip.rb b/superrip.rb index d9ab7d7..b6c5617 100755 --- a/superrip.rb +++ b/superrip.rb @@ -78,18 +78,23 @@ def audiorip(tnum, track) # If there are too many processes, wait for one of them to terminate if ($children.keys.length > $opts.max_children) then - pid = Process.wait(-1) + pid, status = Process.wait2(-1) + if (status.exitstatus != 0) then + raise "process #{pid} failed with exitstatus #{status.exitstatus}" + end $children.delete(pid) end pid = Process.fork if (pid == nil) then + retcode = 0 begin process_wav(track) - Kernel.exit(0) - rescue - Kernel.exit(1) + rescue Exception => e + puts "*** FATAL ERROR: #{e}" + retcode = 1 end + Kernel.exit(retcode) else $children[pid] = 1 end @@ -200,7 +205,12 @@ class Manifest next unless @t.has_key?(tnum) audiorip(tnum, @t[tnum]) end - Process.waitall + prc = Process.waitall + prc.each do |pair| + if (pair[1].exitstatus != 0) then + raise "process #{pair[0]} failed with exitstatus #{pair[1].exitstatus}" + end + end end def inspect