Git Product home page Git Product logo

Comments (11)

jarib avatar jarib commented on July 19, 2024

Hmm, good question. I'll get my hands on a Windows VM and give it a shot.

Until then, you could try something like this and see what happens:

process.duplex = true
process.start
IO.copy_stream(STDIN, process.io.stdin) # if the child process exits, this will raise Errno::EPIPE
process.wait

from childprocess.

mitchellh avatar mitchellh commented on July 19, 2024

I tried that but that actually didn't do anything. It just hung. I even tried a case where the child exits right away (echo foo).

from childprocess.

mitchellh avatar mitchellh commented on July 19, 2024

I got an OKAY workaround. It doesn't work 100% but it doesn't crash, either: hashicorp/vagrant@77c309e~...2f49449

from childprocess.

jarib avatar jarib commented on July 19, 2024

I've pushed a branch that hopefully solves the problem. At least this code now behaves similarily on Unix and Windows (tested on Ruby 2.0.0p353 and Windows 8.1):

proc = ChildProcess.build("ruby", "-e", "p STDIN.tty?; IO.copy_stream(STDIN, STDOUT)")
proc.io.inherit!
proc.start
proc.wait

Can you try out the windows-inherit-stdin branch and report back? No special casing (i.e. duplex = true) of Windows should be necessary.

If it works for you I'll do a bit more testing and then push a release.

from childprocess.

mitchellh avatar mitchellh commented on July 19, 2024

Your example does indeed work, but for some reason Cygwin and SSH isn't seeing it still:

Pseudo-terminal will not be allocated because stdin is not a terminal.
      0 [main] ssh 24220 fhandler_base::dup: dup(some disk file) failed, handle 0, Win32 error 6
dup() in/out/err failed

But from the same environment if I do the ruby -e p STDIN.tty? to ChildProcess, it returns true. Woe! I'll try to investigate further. Perhaps it is a bug with Cygwin/SSH on Cygwin

from childprocess.

mitchellh avatar mitchellh commented on July 19, 2024

Oh! Just kidding, your example fails as well within the context of the Vagrant code, but works in my bundle console. Investigating.

from childprocess.

jarib avatar jarib commented on July 19, 2024

How do you bring Cygwin into the picture? Are you running Ruby from Cygwin as well, or just SSH?

from childprocess.

mitchellh avatar mitchellh commented on July 19, 2024

Sorry Cygwin isn't in the picture. Sorry I wasn't clear I think this actually is working. Im just verifying.

from childprocess.

mitchellh avatar mitchellh commented on July 19, 2024

It works! :) Closing.

from childprocess.

mitchellh avatar mitchellh commented on July 19, 2024

Actually, I should probably leave it open until you merge it.

from childprocess.

jarib avatar jarib commented on July 19, 2024

Great! Merged and released as 0.4.0.

from childprocess.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.