Skip to content

Commit e1dd769

Browse files
committed
Make the spec more robust by guaranteeing the fd is not by anything else
1 parent 5bfd788 commit e1dd769

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

spec/ruby/core/process/spawn_spec.rb

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -706,13 +706,15 @@ def child_pids(pid)
706706
end
707707

708708
it "maps the key to a file descriptor in the child that inherits the file descriptor from the parent specified by the value" do
709-
child_fd = find_unused_fd
710-
args = ruby_cmd(fixture(__FILE__, "map_fd.rb"), args: [child_fd.to_s])
711-
pid = Process.spawn(*args, { child_fd => @io })
712-
Process.waitpid pid
713-
@io.rewind
714-
715-
@io.read.should == "writing to fd: #{child_fd}"
709+
File.open(__FILE__, "r") do |f|
710+
child_fd = f.fileno
711+
args = ruby_cmd(fixture(__FILE__, "map_fd.rb"), args: [child_fd.to_s])
712+
pid = Process.spawn(*args, { child_fd => @io })
713+
Process.waitpid pid
714+
@io.rewind
715+
716+
@io.read.should == "writing to fd: #{child_fd}"
717+
end
716718
end
717719
end
718720
end

0 commit comments

Comments
 (0)