Joe Kutner created JRUBY-6362:
---------------------------------

             Summary: Subprocess IO yields no ouput
                 Key: JRUBY-6362
                 URL: https://jira.codehaus.org/browse/JRUBY-6362
             Project: JRuby
          Issue Type: Bug
            Reporter: Joe Kutner
            Assignee: Thomas E Enebo
         Attachments: subprocess.rb

While trying to fix a JRuby specific bug in Vagrant <http://vagrantup.com/> 
that uses
ChildProcess (<https://github.com/jarib/childprocess>) to execute some 
commands, I found that output cannot always be retrieved from a subprocess.

I've been able to reproduce the bug in a single file here:
https://gist.github.com/1647275

It is creating two ChildProcesses (via the Subprocess class), and executing
them in order.

    Vagrant::Util::Subprocess.new("VBoxManage", "--version").execute
    Vagrant::Util::Subprocess.new("VBoxManage", "--version").execute

In the execute method, a ChildProcess is created:

    process = ChildProcess.build(*@command)
    stdout, stdout_writer = IO.pipe
    stderr, stderr_writer = IO.pipe
    process.io.stdout = stdout_writer
    process.io.stderr = stderr_writer
    process.duplex = true

Then it tried to read the output from the stdout pipe:

    data << io.read_nonblock(READ_CHUNK_SIZE)

The first time, the ChildProcess works correctly, but the second time it
yields no output.

 INFO subprocess: Starting process: ["VBoxManage", "--version"]
DEBUG subprocess: Selecting on IO
DEBUG subprocess: stdout: 4.1.8r75467

DEBUG subprocess: Waiting for process to exit. Remaining to timeout: 32000
DEBUG subprocess: Exit status: 0
 INFO subprocess: Starting process: ["VBoxManage", "--version"]
DEBUG subprocess: Selecting on IO
DEBUG subprocess: Waiting for process to exit. Remaining to timeout: 31999
DEBUG subprocess: Exit status: 0

Reproduce with this script:
https://gist.github.com/1647275

Background: 
http://markmail.org/thread/e7rmwy4jp53e3wjj
https://github.com/mitchellh/vagrant/issues/658




--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://jira.codehaus.org/secure/ContactAdministrators!default.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