Hi,

Can someone explain why this code:

-----------------------------------------
fork do 
  puts("Child's PID: #{Process.pid}")
end

trap(:SIGCHLD) do
  $pid = Process.wait
end

puts("Parent's PID: #{Process.pid}")
puts("My son is no more a zombie (check with ps)...")

sleep(20)

if $?.exitstatus == 0
  puts("#{$pid} died gracefully")
else
  puts("#{$pid} doesn't die gracefully")
end
exit(0) 
-----------------------------------------

doesn't work as i expect (it seems the sleep is never called: the
parent process exit immediately after it get SIGCHLD...).

The same script, with the trap commented out work ok (the child
process is a zombie during 20 sec).

And, yes, i know about Process.detach but that's a try to mimic a C
idiom.

-- 
Eric Jacoboni, ne il y a 1443482274 secondes