Project

General

Profile

Actions

Bug #13744

closed

Spawn doesn't work with options of symbol keys generated dynamically

Added by satoryu (Tatsuya Sato) over 6 years ago. Updated over 6 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.5.0dev (2017-07-13 trunk 59321) [x86_64-darwin16]
[ruby-core:82033]

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>'

Updated by shevegen (Robert A. Heiler) over 6 years ago

Very interesting behaviour. I would have assumed for both to behave the same in the above case.

Updated by Hanmac (Hans Mackowiak) over 6 years ago

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

Updated by normalperson (Eric Wong) over 6 years ago

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...

Actions #4

Updated by Anonymous over 6 years ago

  • 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]

Updated by normalperson (Eric Wong) over 6 years ago

  • 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

Updated by normalperson (Eric Wong) over 6 years ago

  • Status changed from Open to Closed

reclosing to trigger backport request

Actions #7

Updated by usa (Usaku NAKAMURA) over 6 years ago

  • 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.

Updated by nagachika (Tomoyuki Chikanaga) over 6 years ago

  • 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.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0