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.
# 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
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