exit()
and abort()
don't kill the parent, at least not on Mac OS, and Linux in my experience.
Try saving this as abort.rb
:
puts RUBY_VERSION
puts `date`
puts 'aborting'
abort
and this as exit.rb
:
puts RUBY_VERSION
puts `date`
puts 'exiting'
exit
Then save this as test.rb
in the same directory and run it:
puts `ruby exit.rb`
puts `ruby abort.rb`
On my system I see:
1.9.3
Fri Dec 21 22:17:12 MST 2012
exiting
1.9.3
Fri Dec 21 22:17:12 MST 2012
aborting
They do exit the currently running script in the sub-shell, which then exits because it's not a log-in shell, and could set a return status which is important to the calling program, but I have yet to see them kill the parent.
If you need to capture STDERR, using backticks or %x
won't work. I'd recommend using Open3.capture3
for simplicity if you need to know what status code was returned, or whether STDERR returned anything.