chruby icon indicating copy to clipboard operation
chruby copied to clipboard

Terminating chruby does not terminate child processes

Open yorickpeterse opened this issue 11 years ago • 2 comments

When running chruby along the lines of `bash -l -c 'chruby-exec 1.9.3 -- some_script.rb' killing the top level chruby process does not terminate the underlying Ruby script.

A simple example:

# /tmp/test.rb
%w{QUIT KILL TERM}.each do |signal|
  trap signal do
    exit
  end
end

loop do
  sleep 5
end

Running the command pseudo-monit style (you can also leave the sudo bit out if you run it as the correct user, it won't make a difference):

sudo -H -u your-user-since-this-is-run-as-root bash -l -c "/usr/bin/chruby-exec 1.9.3 -- ruby /tmp/test.rb"

Killing the process (TERM and INT don't do anything so you have to use KILL):

kill -9 `pidof sudo` # lets hope you don't have anything else running with sudo

This results in the chruby command being killed while the underlying Ruby script remains active.

yorickpeterse avatar Jun 14 '13 08:06 yorickpeterse

Bummer. This prevents me from using chruby with runit.

AlekSi avatar Oct 20 '14 14:10 AlekSi

Bummer. This prevents me from using chruby with supervisor.

cjbottaro avatar Mar 09 '16 19:03 cjbottaro