Skip to content

Instantly share code, notes, and snippets.

@chrismo
Created November 7, 2012 15:44
Show Gist options
  • Save chrismo/4032347 to your computer and use it in GitHub Desktop.
Save chrismo/4032347 to your computer and use it in GitHub Desktop.
Using at_exit with fork
child = fork do
at_exit { $stderr.puts "Child one is done." }
exit # superfluous
end
Process.wait
$stderr.puts "Parent is done waiting for child one #{child}."
child = fork do
at_exit { $stderr.puts "This won't get hit." }
exit!
end
Process.wait
$stderr.puts "Parent is done waiting for child two #{child}."
at_exit { $stderr.puts "Parent registered at_exit forked into child. #{Process.pid}"}
child = fork do
exit # superfluous
end
Process.wait
$stderr.puts "Parent is done waiting for child three #{child}."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment