Bug #13744 closed
Spawn doesn't work with options of symbol keys generated dynamically
Added by satoryu (Tatsuya Sato) over 7 years ago.
Updated over 7 years ago.
Description
spawn works when giving options whose key is symbol literal:
$ ruby -e 'spawn("ls", :rlimit_cpu => 100)'
But spawn fails when generating symbol from a String:
$ ruby -e 'spawn("ls", "rlimit_cpu".to_sym => 100)'
-e:1:in `spawn': wrong exec option symbol: rlimit_cpu (ArgumentError)
from -e:1:in `<main>'
Very interesting behaviour. I would have assumed for both to behave the same in the above case.
hm on my windows machine:
ruby -e 'spawn("ls", :rlimit_cpu => 100)'
causes a syntax error
PS:
i did install ruby in my mingw (ruby 2.3.3p222), there i get similar problem like yours:
$ ruby -e 'spawn("ls", :rlimit_cpu => 100)'
-e:1:in `spawn': Invalid argument - setrlimit (Errno::EINVAL)
from -e:1:in `<main>'
this was suspected because my machine doesn't support it
$ ruby -e 'spawn("ls", "rlimit_cpu".to_sym => 100)'
-e:1:in `spawn': wrong exec option symbol: rlimit_cpu (ArgumentError)
from -e:1:in `<main>'
this was the same error as yours.
seems it has a difference between a symbol literal and a real symbol at this part of code
satoryu.1981@gmail.com wrote:
But spawn fails when generating symbol from a String:
$ ruby -e 'spawn("ls", "rlimit_cpu".to_sym => 100)'
-e:1:in `spawn': wrong exec option symbol: rlimit_cpu (ArgumentError)
from -e:1:in `<main>'
This seems to be a problem with dynamic symbols,
investigating...
Status changed from Open to Closed
Applied in changeset trunk|r59322.
process.c: handle dynamic :rlimit_* symbols in spawn execopts
process.c (rb_execarg_addopt_rlimit): hoist out of rb_execarg_addopt
(rlimit_type_by_sym): new wrapper for dynamic symbol
(rb_execarg_addopt): check for dsym via rlimit_type_by_sym
test/ruby/test_process.rb (test_execopts_rlimit): check dsym w/o pindown
Add extra check for bogus rlimit args, too.
[ruby-core:82033] [Bug #13744 ]
Status changed from Closed to Open
Backport changed from 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN to 2.2: REQUIRED, 2.3: REQUIRED, 2.4: REQUIRED
fixed in r59322, will need backports
Status changed from Open to Closed
reclosing to trigger backport request
Backport changed from 2.2: REQUIRED, 2.3: REQUIRED, 2.4: REQUIRED to 2.2: REQUIRED, 2.3: DONE, 2.4: REQUIRED
ruby_2_3 r59531 merged revision(s) 59322,59325.
Backport changed from 2.2: REQUIRED, 2.3: DONE, 2.4: REQUIRED to 2.2: REQUIRED, 2.3: DONE, 2.4: DONE
ruby_2_4 r59809 merged revision(s) 59322,59325.
Also available in: Atom
PDF
Like 0
Like 0 Like 0 Like 0 Like 0 Like 0 Like 0 Like 0 Like 0