popen process shutdown does not work like MRI
---------------------------------------------

                 Key: JRUBY-4110
                 URL: http://jira.codehaus.org/browse/JRUBY-4110
             Project: JRuby
          Issue Type: Bug
          Components: Core Classes/Modules, RubySpec
    Affects Versions: JRuby 1.4.0RC1
            Reporter: Charles Oliver Nutter


This is a vague bug because I only have vague facts to go on.

This spec:

{noformat}
  it "sets $?" do
    io = IO.popen 'true', 'r'
    io.close

    $?.exitstatus.should == 0

    io = IO.popen 'false', 'r'
    io.close

    $?.exitstatus.should == 1
  end
{noformat}

...fails intermittently because when we do io.close on a popen'ed stream, we 
use java.lang.Process.destroy to ensure it terminates. In hotspot, this results 
in a SIGTERM being sent to the child process, which causes the exit value to be 
"143" instead of the actual exit value if the process has not completed. MRI 
does not explicitly signal the child process, instead just closing its IO 
streams and allowing it to terminate based on that.

Simply removing the call to Process.destroy caused simple long-running scripts 
to not IO#close properly, such as:

{noformat}
jruby -e "io = IO.popen('yes', 'r'); io.close"
{noformat}

This may be because the fork/exec logic in the JVM does not directly connect 
the child streams with the ones we have in the Process object, and as a result 
closing the streams we can access has no effect on the child process.

I have (re)tagged this spec for now until we can investigate making 
process-management more like MRI, to ensure that processes can terminate 
gracefully rather than being forcibly shut down.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to