diff --git a/spec/core/io/close_spec.rb b/spec/core/io/close_spec.rb index beacb3073..4a168e9c0 100644 --- a/spec/core/io/close_spec.rb +++ b/spec/core/io/close_spec.rb @@ -88,7 +88,6 @@ end describe "IO#close on an IO.popen stream" do - it "clears #pid" do io = IO.popen ruby_cmd('r = loop{puts "y"; 0} rescue 1; exit r'), 'r' @@ -103,25 +102,18 @@ io = IO.popen ruby_cmd('exit 0'), 'r' io.close - NATFIXME 'Handle $? with IO.popen', exception: NoMethodError, message: "undefined method `exitstatus' for nil" do - $?.exitstatus.should == 0 - end + $?.exitstatus.should == 0 io = IO.popen ruby_cmd('exit 1'), 'r' io.close - NATFIXME 'Handle $? with IO.popen', exception: NoMethodError, message: "undefined method `exitstatus' for nil" do - $?.exitstatus.should == 1 - end + $?.exitstatus.should == 1 end it "waits for the child to exit" do io = IO.popen ruby_cmd('r = loop{puts "y"; 0} rescue 1; exit r'), 'r' io.close - NATFIXME 'Handle $? with IO.popen', exception: NoMethodError, message: "undefined method `exitstatus' for nil" do - $?.exitstatus.should_not == 0 - end + $?.exitstatus.should_not == 0 end - end diff --git a/spec/core/io/popen_spec.rb b/spec/core/io/popen_spec.rb index 930b7ea73..ec5094be2 100644 --- a/spec/core/io/popen_spec.rb +++ b/spec/core/io/popen_spec.rb @@ -39,9 +39,7 @@ io = IO.popen ruby_cmd('r = loop{puts "y"; 0} rescue 1; exit r'), 'r' io.close - NATFIXME 'Handle $? with IO.popen', exception: NoMethodError, message: "undefined method `exitstatus' for nil" do - $?.exitstatus.should_not == 0 - end + $?.exitstatus.should_not == 0 end it "writes to a write-only pipe" do @@ -70,9 +68,7 @@ @io.write("bar") @io.close - NATFIXME 'Handle $? with IO.popen', exception: NoMethodError, message: "undefined method `exitstatus' for nil" do - $?.exitstatus.should == 0 - end + $?.exitstatus.should == 0 File.read(@fname).should == "bar" end diff --git a/src/io_object.cpp b/src/io_object.cpp index 55285a610..d41f4a217 100644 --- a/src/io_object.cpp +++ b/src/io_object.cpp @@ -703,6 +703,7 @@ Value IoObject::close(Env *env) { int result; if (m_fileptr && m_pid > 0) { result = pclose2(m_fileptr, m_pid); + set_status_object(env, m_pid, result); } else { result = ::close(m_fileno); }