Permalink
Browse files

Add specs for :close_others option to Process.spawn

  • Loading branch information...
1 parent 9bf7e0a commit 5052b62f9c2cc059d1f970a1ca3d54bd612e41ea @jfirebaugh jfirebaugh committed May 7, 2012
Showing with 26 additions and 0 deletions.
  1. +26 −0 spec/ruby/shared/process/spawn.rb
@@ -390,6 +390,32 @@
# :close_others
+ it "closes file descriptors >= 3 in the child process" do
+ IO.pipe do |r, w|
+ begin
+ pid = @object.spawn(ruby_cmd("sleep"))
+ w.close
+ lambda { r.read_nonblock(1) }.should raise_error(EOFError)
+ ensure
+ Process.kill(:TERM, pid)
+ Process.wait(pid)
+ end
+ end
+ end
+
+ it "does not close file descriptors >= 3 in the child process when given a false :close_others option" do
+ IO.pipe do |r, w|
+ begin
+ pid = @object.spawn(ruby_cmd("sleep"), :close_others => false)
+ w.close
+ lambda { r.read_nonblock(1) }.should raise_error(Errno::EAGAIN)
+ ensure
+ Process.kill(:TERM, pid)
+ Process.wait(pid)
+ end
+ end
+ end
+
# error handling
it "raises an ArgumentError if passed no command arguments" do

0 comments on commit 5052b62

Please sign in to comment.