ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:61401] [ruby-trunk - Bug #9617] [Open] Windows7 issue with Kernel.spawn close_others => false
       [not found] <redmine.issue-9617.20140310110228@ruby-lang.org>
@ 2014-03-10 11:02 ` lionel.perrin
  2014-03-10 23:19 ` [ruby-core:61405] [ruby-trunk - Bug #9617] [Rejected] " usa
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 5+ messages in thread
From: lionel.perrin @ 2014-03-10 11:02 UTC (permalink / raw
  To: ruby-core

Issue #9617 has been reported by Lionel PERRIN.

----------------------------------------
Bug #9617: Windows7 issue with Kernel.spawn close_others => false
https://bugs.ruby-lang.org/issues/9617

* Author: Lionel PERRIN
* Status: Open
* Priority: Normal
* Assignee: 
* Category: platform/mingw
* Target version: 
* ruby -v: ruby 2.0.0p451 (2014-02-24) [i386-mingw32]
* Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
I faced an issue while trying to inherit a file or pipe handle from a master process to its child on windows 7.

I tried this implementation:

* master.rb:

~~~
rd, wr = IO.pipe
puts "Pipe opened: #{rd.fileno} <= #{wr.fileno}"
cmd = "ruby child.rb #{rd.fileno}"
pid = Kernel.spawn cmd, :close_others => false
wr.write "Hello World\n"
Process.wait pid
~~~

* child.rb:

~~~
puts "Child:Start #{ARGV}"
rd = IO.new(ARGV[0].to_i, mode: "r")
puts rd.read
~~~

On windows I get the following output while it works fine on linux.

~~~
Pipe opened: 3 <= 4
Child:Start ["3"]
child.rb:2:in `initialize': Bad file descriptor (Errno::EBADF)
        from child.rb:2:in `new'
        from child.rb:2:in `<main>'
~~~

Note: the same test with the fileno of a file opened from master.rb lead to the same exception in child.rb




-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:61405] [ruby-trunk - Bug #9617] [Rejected] Windows7 issue with Kernel.spawn close_others => false
       [not found] <redmine.issue-9617.20140310110228@ruby-lang.org>
  2014-03-10 11:02 ` [ruby-core:61401] [ruby-trunk - Bug #9617] [Open] Windows7 issue with Kernel.spawn close_others => false lionel.perrin
@ 2014-03-10 23:19 ` usa
  2014-03-11 11:14 ` [ruby-core:61411] [ruby-trunk - Bug #9617] " lionel.perrin
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 5+ messages in thread
From: usa @ 2014-03-10 23:19 UTC (permalink / raw
  To: ruby-core

Issue #9617 has been updated by Usaku NAKAMURA.

Status changed from Open to Rejected

It is not supported on mswin/mingw to pass file descriptors (except 0,1,2) to other processes.
So, it is expected behavior.

----------------------------------------
Bug #9617: Windows7 issue with Kernel.spawn close_others => false
https://bugs.ruby-lang.org/issues/9617#change-45714

* Author: Lionel PERRIN
* Status: Rejected
* Priority: Normal
* Assignee: 
* Category: platform/mingw
* Target version: 
* ruby -v: ruby 2.0.0p451 (2014-02-24) [i386-mingw32]
* Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
I faced an issue while trying to inherit a file or pipe handle from a master process to its child on windows 7.

I tried this implementation:

* master.rb:

~~~
rd, wr = IO.pipe
puts "Pipe opened: #{rd.fileno} <= #{wr.fileno}"
cmd = "ruby child.rb #{rd.fileno}"
pid = Kernel.spawn cmd, :close_others => false
wr.write "Hello World\n"
Process.wait pid
~~~

* child.rb:

~~~
puts "Child:Start #{ARGV}"
rd = IO.new(ARGV[0].to_i, mode: "r")
puts rd.read
~~~

On windows I get the following output while it works fine on linux.

~~~
Pipe opened: 3 <= 4
Child:Start ["3"]
child.rb:2:in `initialize': Bad file descriptor (Errno::EBADF)
        from child.rb:2:in `new'
        from child.rb:2:in `<main>'
~~~

Note: the same test with the fileno of a file opened from master.rb lead to the same exception in child.rb




-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:61411] [ruby-trunk - Bug #9617] Windows7 issue with Kernel.spawn close_others => false
       [not found] <redmine.issue-9617.20140310110228@ruby-lang.org>
  2014-03-10 11:02 ` [ruby-core:61401] [ruby-trunk - Bug #9617] [Open] Windows7 issue with Kernel.spawn close_others => false lionel.perrin
  2014-03-10 23:19 ` [ruby-core:61405] [ruby-trunk - Bug #9617] [Rejected] " usa
@ 2014-03-11 11:14 ` lionel.perrin
  2014-03-11 11:43 ` [ruby-core:61412] " usa
  2014-03-15 14:41 ` [ruby-core:61515] " akr
  4 siblings, 0 replies; 5+ messages in thread
From: lionel.perrin @ 2014-03-11 11:14 UTC (permalink / raw
  To: ruby-core

Issue #9617 has been updated by Lionel PERRIN.


Thanks for the answer.

Two last questions:

* Is there a technical reason why it is not supported ?

I've looked at the ruby source code. From my understanding, the CreateProcess call is made with inheritHandles set to true, which should make possible to transfer handles. Nevertheless, CreatePipe call is made in a way that forbid this handle to be inherited. Wouldn't it be possible to change this ?

* Wouldn't it be worth updating the documentation ? It is not specified that the Kernel.spawn command is limited on windows.

----------------------------------------
Bug #9617: Windows7 issue with Kernel.spawn close_others => false
https://bugs.ruby-lang.org/issues/9617#change-45721

* Author: Lionel PERRIN
* Status: Rejected
* Priority: Normal
* Assignee: 
* Category: platform/mingw
* Target version: 
* ruby -v: ruby 2.0.0p451 (2014-02-24) [i386-mingw32]
* Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
I faced an issue while trying to inherit a file or pipe handle from a master process to its child on windows 7.

I tried this implementation:

* master.rb:

~~~
rd, wr = IO.pipe
puts "Pipe opened: #{rd.fileno} <= #{wr.fileno}"
cmd = "ruby child.rb #{rd.fileno}"
pid = Kernel.spawn cmd, :close_others => false
wr.write "Hello World\n"
Process.wait pid
~~~

* child.rb:

~~~
puts "Child:Start #{ARGV}"
rd = IO.new(ARGV[0].to_i, mode: "r")
puts rd.read
~~~

On windows I get the following output while it works fine on linux.

~~~
Pipe opened: 3 <= 4
Child:Start ["3"]
child.rb:2:in `initialize': Bad file descriptor (Errno::EBADF)
        from child.rb:2:in `new'
        from child.rb:2:in `<main>'
~~~

Note: the same test with the fileno of a file opened from master.rb lead to the same exception in child.rb




-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:61412] [ruby-trunk - Bug #9617] Windows7 issue with Kernel.spawn close_others => false
       [not found] <redmine.issue-9617.20140310110228@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2014-03-11 11:14 ` [ruby-core:61411] [ruby-trunk - Bug #9617] " lionel.perrin
@ 2014-03-11 11:43 ` usa
  2014-03-15 14:41 ` [ruby-core:61515] " akr
  4 siblings, 0 replies; 5+ messages in thread
From: usa @ 2014-03-11 11:43 UTC (permalink / raw
  To: ruby-core

Issue #9617 has been updated by Usaku NAKAMURA.


Lionel PERRIN wrote:
> * Is there a technical reason why it is not supported ?
> 
> I've looked at the ruby source code. From my understanding, the CreateProcess call is made with inheritHandles set to true, which should make possible to transfer handles. Nevertheless, CreatePipe call is made in a way that forbid this handle to be inherited. Wouldn't it be possible to change this ?

We do not have a way how specify which handle corresponds to which file descriptor to a child process.
First of all, we do not know whether a child process treats file descriptors or not.


> * Wouldn't it be worth updating the documentation ? It is not specified that the Kernel.spawn command is limited on windows.

I think so, too.


----------------------------------------
Bug #9617: Windows7 issue with Kernel.spawn close_others => false
https://bugs.ruby-lang.org/issues/9617#change-45722

* Author: Lionel PERRIN
* Status: Rejected
* Priority: Normal
* Assignee: 
* Category: platform/mingw
* Target version: 
* ruby -v: ruby 2.0.0p451 (2014-02-24) [i386-mingw32]
* Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
I faced an issue while trying to inherit a file or pipe handle from a master process to its child on windows 7.

I tried this implementation:

* master.rb:

~~~
rd, wr = IO.pipe
puts "Pipe opened: #{rd.fileno} <= #{wr.fileno}"
cmd = "ruby child.rb #{rd.fileno}"
pid = Kernel.spawn cmd, :close_others => false
wr.write "Hello World\n"
Process.wait pid
~~~

* child.rb:

~~~
puts "Child:Start #{ARGV}"
rd = IO.new(ARGV[0].to_i, mode: "r")
puts rd.read
~~~

On windows I get the following output while it works fine on linux.

~~~
Pipe opened: 3 <= 4
Child:Start ["3"]
child.rb:2:in `initialize': Bad file descriptor (Errno::EBADF)
        from child.rb:2:in `new'
        from child.rb:2:in `<main>'
~~~

Note: the same test with the fileno of a file opened from master.rb lead to the same exception in child.rb




-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:61515] [ruby-trunk - Bug #9617] Windows7 issue with Kernel.spawn close_others => false
       [not found] <redmine.issue-9617.20140310110228@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2014-03-11 11:43 ` [ruby-core:61412] " usa
@ 2014-03-15 14:41 ` akr
  4 siblings, 0 replies; 5+ messages in thread
From: akr @ 2014-03-15 14:41 UTC (permalink / raw
  To: ruby-core

Issue #9617 has been updated by Akira Tanaka.


Documentation patch is welcome.

----------------------------------------
Bug #9617: Windows7 issue with Kernel.spawn close_others => false
https://bugs.ruby-lang.org/issues/9617#change-45804

* Author: Lionel PERRIN
* Status: Rejected
* Priority: Normal
* Assignee: 
* Category: platform/mingw
* Target version: 
* ruby -v: ruby 2.0.0p451 (2014-02-24) [i386-mingw32]
* Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
I faced an issue while trying to inherit a file or pipe handle from a master process to its child on windows 7.

I tried this implementation:

* master.rb:

~~~
rd, wr = IO.pipe
puts "Pipe opened: #{rd.fileno} <= #{wr.fileno}"
cmd = "ruby child.rb #{rd.fileno}"
pid = Kernel.spawn cmd, :close_others => false
wr.write "Hello World\n"
Process.wait pid
~~~

* child.rb:

~~~
puts "Child:Start #{ARGV}"
rd = IO.new(ARGV[0].to_i, mode: "r")
puts rd.read
~~~

On windows I get the following output while it works fine on linux.

~~~
Pipe opened: 3 <= 4
Child:Start ["3"]
child.rb:2:in `initialize': Bad file descriptor (Errno::EBADF)
        from child.rb:2:in `new'
        from child.rb:2:in `<main>'
~~~

Note: the same test with the fileno of a file opened from master.rb lead to the same exception in child.rb




-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-03-15 14:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <redmine.issue-9617.20140310110228@ruby-lang.org>
2014-03-10 11:02 ` [ruby-core:61401] [ruby-trunk - Bug #9617] [Open] Windows7 issue with Kernel.spawn close_others => false lionel.perrin
2014-03-10 23:19 ` [ruby-core:61405] [ruby-trunk - Bug #9617] [Rejected] " usa
2014-03-11 11:14 ` [ruby-core:61411] [ruby-trunk - Bug #9617] " lionel.perrin
2014-03-11 11:43 ` [ruby-core:61412] " usa
2014-03-15 14:41 ` [ruby-core:61515] " akr

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).