jarib/childprocess — Issue #21: IO.pipe not working with Windows API?
Author: mitchellh
Created: 2012-01-05 07:24:30+00:00
State: open

Hey Jarib,

Not sure if I'm just doing something wrong but the following simple case seems to not work on Windows... but it should, since it is how libraries such as `mixlib-shellout` which powers Chef work with Windows[1]

```ruby
require "rubygems"
require "childprocess"

p = ChildProcess.build("ipconfig")

# Setup the stdout/stderr pipes
stdout, stdout_w = IO.pipe
stderr, stderr_w = IO.pipe
p.io.stdout = stdout_w
p.io.stderr = stderr_w
p.duplex = true

p.start

# Close our write handles, since we don't use them
stdout_w.close
stdout_err.close

# Wait for the process to exit
p.exit

# Output the data:
p stdout.read
p stderr.read
```

The above will always output "" (empty string) for stdout and stderr, but if you remove all the pipe stuff (so the process just inherits the pipes), then it will properly output all the ipconfig data.

I'm not sure if I'm doing something wrong but its such a simple case I'm not sure how I can be.

Any ideas?

[1]: https://github.com/opscode/mixlib-shellout/blob/master/lib/mixlib/shellout/windows.rb#L43