Skip to content

Commit 5bfd788

Browse files
committed
Do not assume the next fd is always free in Process.exec specs
* It might be useful by something else until the execve(2) call.
1 parent 51403f6 commit 5bfd788

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

spec/ruby/core/process/exec_spec.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,11 @@
193193
map_fd_fixture = fixture __FILE__, "map_fd.rb"
194194
cmd = <<-EOC
195195
f = File.open(#{@name.inspect}, "w+")
196-
child_fd = f.fileno + 1
197-
File.open(#{@child_fd_file.inspect}, "w") { |io| io.print child_fd }
198-
Process.exec "#{ruby_cmd(map_fd_fixture)} \#{child_fd}", { child_fd => f }
196+
File.open(#{__FILE__.inspect}, "r") do |io|
197+
child_fd = io.fileno
198+
File.open(#{@child_fd_file.inspect}, "w") { |io| io.print child_fd }
199+
Process.exec "#{ruby_cmd(map_fd_fixture)} \#{child_fd}", { child_fd => f }
200+
end
199201
EOC
200202

201203
ruby_exe(cmd, escape: true)

0 commit comments

Comments
 (0)