Skip to content

Commit

Permalink
Process#stop: make sure the full process tree is killed (on Unix). See
Browse files Browse the repository at this point in the history
  • Loading branch information
jarib committed Jan 30, 2014
1 parent 04c9591 commit cfcad4d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -20,5 +20,6 @@ pkg
.rbx
Gemfile.lock
.ruby-version
.bundle

## PROJECT::SPECIFIC
2 changes: 2 additions & 0 deletions lib/childprocess/unix/fork_exec_process.rb
Expand Up @@ -18,6 +18,8 @@ def launch_process
end

@pid = fork {
::Process.setpgid 0, 0 # same process group as parent

if @cwd
Dir.chdir(@cwd)
end
Expand Down
7 changes: 2 additions & 5 deletions lib/childprocess/unix/posix_spawn_process.rb
Expand Up @@ -34,11 +34,8 @@ def launch_process
actions.add_close fileno_for(writer)
end

if defined? Platform::POSIX_SPAWN_USEVFORK
flags |= Platform::POSIX_SPAWN_USEVFORK
end

attrs.flags = flags
attrs.flags = flags | Platform::POSIX_SPAWN_SETPGROUP
attrs.flags |= Platform::POSIX_SPAWN_USEVFORK if defined? Platform::POSIX_SPAWN_USEVFORK

# wrap in helper classes in order to avoid GC'ed pointers
argv = Argv.new(@args)
Expand Down
2 changes: 1 addition & 1 deletion lib/childprocess/unix/process.rb
Expand Up @@ -66,7 +66,7 @@ def send_signal(sig)
assert_started

log "sending #{sig}"
::Process.kill sig, @pid
::Process.kill sig, -@pid
end

end # Process
Expand Down

0 comments on commit cfcad4d

Please sign in to comment.