Project

General

Profile

Actions

Bug #11350

closed

When Process.exec failed, redirections were still changed and not restored

Added by ngoto (Naohisa Goto) over 9 years ago. Updated over 9 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:69961]

Description

When Process.exec failed, redirections of file descriptors were changed and not restored.

When redirecting fd 3 or 5, ASYNC BUG occurred as below.

$ ruby -e 'begin; Process.exec("/does_not_exist", "arg", { 3=>["/dev/null", "w"]}); rescue Errno::ENOENT => e; $stdout.print "stdout: ", e.inspect, "\n"; $stderr.print "stderr: ", e.inspect, "\n"; end'
[ASYNC BUG] consume_communication_pipe: read

EBADF

ruby 2.3.0dev (2015-07-13) [sparc64-solaris2.10]

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

stdout: #<Errno::ENOENT: No such file or directory - /does_not_exist>
stderr: #<Errno::ENOENT: No such file or directory - /does_not_exist>Abort
$ ruby -e 'begin; Process.exec("/does_not_exist", "arg", { 5=>["/dev/null", "w"]}); rescue Errno::ENOENT => e; $stdout.print "stdout: ", e.inspect, "\n"; $stderr.print "stderr: ", e.inspect, "\n"; end'
[ASYNC BUG] consume_communication_pipe: read

EBADF

ruby 2.3.0dev (2015-07-13) [sparc64-solaris2.10]

stdout: [NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

#<Errno::ENOENT: No such file or directory - /does_not_exist>
stderr: #<Errno::ENOENT: No such file or directory - /does_not_exist>Abort

When redirecting fd 1 or 2 to /dev/null, stdout or stderr is still redirected to /dev/null and the printed contents are not shown.

% ruby -e 'begin; Process.exec("/does_not_exist", "arg", { 1=>["/dev/null", "w"]}); rescue Errno::ENOENT => e; $stdout.print "stdout: ", e.inspect, "\n"; $stderr.print "stderr: ", e.inspect, "\n"; end'
stderr: #<Errno::ENOENT: No such file or directory - /does_not_exist>
% ruby -e 'begin; Process.exec("/does_not_exist", "arg", { 2=>["/dev/null", "w"]}); rescue Errno::ENOENT => e; $stdout.print "stdout: ", e.inspect, "\n"; $stderr.print "stderr: ", e.inspect, "\n"; end'
stdout: #<Errno::ENOENT: No such file or directory - /does_not_exist>

All of the above are observed both on x86_64 Linux and sparc Solaris.

Is this spec or bug?


Related issues 2 (0 open2 closed)

Related to Ruby master - Bug #11336: TestProcess#test_exec_fd_3_redirect failed on Solaris 10ClosedActions
Related to Ruby master - Bug #11353: ASYNC BUG after failure of Process.exec when closing FD 3 (or 4 or 5)ClosedActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0