Project

General

Profile

Actions

Backport #7358

closed

Wrong fd redirection on fork

Added by felipec (Felipe Contreras) over 11 years ago. Updated over 6 years ago.

Status:
Rejected
[ruby-core:49370]

Description

It seems fd redirecton only works with spawn, not with fork+exec (at least for fd 3).

% ruby -v
ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-linux]

#!/usr/bin/env ruby

tmp = File.new('/tmp/foo', File::CREAT | File::WRONLY)
cmd = ['echo', 'yes']

pid = Process.spawn(*cmd, 3 => tmp)
Process.wait(pid)

pid = fork do
Process.exec(*cmd, :close_others => true, 3 => tmp)
end
Process.wait(pid)

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0