Exception of "invalid first argument" in Process.spawn

I am trying to create a process like this

# name I get from network (I'm using webrick)
Process.spawn(name)

however I end up being

ArgumentError: wrong first argument

But this is a little strange. When I use binding.pryto break right in front Process.spawn, this is what I get:

> name
=> "notepad.exe"
> name == "notepad.exe"
=> true
> Process.spawn(name)
ArgumentError: wrong first argument
from (pry):23: in `spawn`
> Process.spawn("notepad.exe")
=> 728
> Process.spawn(name.to_s)
=> 1416

So, I just confirmed that namethe same "notepad.exe"and Process.spawn fails when called with nameand performed by a call using "notepad.exe". This also works when called with name.to_s. Can someone explain to me what is going on?

Both nameand "notepad.exe"are UTF-8encoding (confirmation name.encoding) and no name, or name.to_snot tainted?.

I looked at the source code but have no idea what is going on.

Thank.

+4
1

, WEBrick::HTTPUtils::FormData #to_ary. name.to_s.

+2

Source: https://habr.com/ru/post/1685031/


All Articles