Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fspawn :pgroup option implementation

  • Loading branch information...
commit 9b614915333f915a5ae447fedb12364c902a3ddf 1 parent cd2b655
Ryan Tomayko rtomayko authored

Showing 1 changed file with 7 additions and 1 deletion. Show diff stats Hide diff stats

  1. +7 1 lib/posix/spawn.rb
8 lib/posix/spawn.rb
@@ -159,8 +159,9 @@ def pspawn(*args)
159 159 # the POSIX::Spawn module documentation.
160 160 def fspawn(*args)
161 161 env, argv, options = extract_process_spawn_arguments(*args)
  162 + valid_options = [:chdir, :unsetenv_others, :pgroup]
162 163
163   - if badopt = options.find{ |key,val| !fd?(key) && ![:chdir,:unsetenv_others].include?(key) }
  164 + if badopt = options.find{ |key,val| !fd?(key) && !valid_options.include?(key) }
164 165 raise ArgumentError, "Invalid option: #{badopt[0].inspect}"
165 166 elsif !argv.is_a?(Array) || !argv[0].is_a?(Array) || argv[0].size != 2
166 167 raise ArgumentError, "Invalid command name"
@@ -196,6 +197,11 @@ def fspawn(*args)
196 197 # { :chdir => '/' } in options means change into that dir
197 198 ::Dir.chdir(options[:chdir]) if options[:chdir]
198 199
  200 + # { :pgroup => pgid } options
  201 + pgroup = options[:pgroup]
  202 + pgroup = 0 if pgroup == true
  203 + Process::setpgid(0, pgroup) if pgroup
  204 +
199 205 # do the deed
200 206 ::Kernel::exec(*argv)
201 207 ensure

0 comments on commit 9b61491

Please sign in to comment.
Something went wrong with that request. Please try again.