From 32830ca1bcd155b9458d30f67e2bc4b5d9324e45 Mon Sep 17 00:00:00 2001 From: Colin Patrick McCabe Date: Sat, 3 Apr 2010 13:58:45 -0700 Subject: [PATCH] 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. --- superrip.rb | 20 +++++++++++++++----- 1 files changed, 15 insertions(+), 5 deletions(-) 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 -- 1.6.6.rc1.39.g9a42