Comments (11)
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.
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.
I got an OKAY workaround. It doesn't work 100% but it doesn't crash, either: hashicorp/vagrant@77c309e~...2f49449
from childprocess.
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.
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.
Oh! Just kidding, your example fails as well within the context of the Vagrant code, but works in my bundle console
. Investigating.
from childprocess.
How do you bring Cygwin into the picture? Are you running Ruby from Cygwin as well, or just SSH?
from childprocess.
Sorry Cygwin isn't in the picture. Sorry I wasn't clear I think this actually is working. Im just verifying.
from childprocess.
It works! :) Closing.
from childprocess.
Actually, I should probably leave it open until you merge it.
from childprocess.
Great! Merged and released as 0.4.0.
from childprocess.
Related Issues (20)
- Redirect to IO.pipe on Windows causes inability to start a process HOT 6
- Security Question: Is there a reason childprocess is released as an unsigned gem? HOT 2
- FFI is a required pre-requisite HOT 4
- Pipe i/o example in documentation is incorrect HOT 2
- Erro ao rodar o comando rspec -fd HOT 1
- childprocess kills detached windows process on exit HOT 4
- FFI is a required pre-requisite for Windows or posix_spawn support in the ChildProcess gem. HOT 1
- A backend based on Process.spawn HOT 12
- Ruby 3.0 support HOT 10
- code hanging attempting to @thread.join HOT 1
- Should work for the M1 chip, but needs to be mapped or smth
- `host_cpu` changes between Ruby 2.7.2 and 2.7.3 HOT 2
- FFI installes but rake test get error HOT 4
- cannot load such file -- ffi (LoadError) HOT 2
- Use with StringIO HOT 1
- posix_spawn is not yet supported on aarch64-linux (aarch64-linux), HOT 2
- posix_spawn is not yet supported on sparc-solaris (sparc-solaris2.11) HOT 1
- I happen to be having this error after even having all both ruby, gem, and even chocolatey handy HOT 2
- Test suite is going to be broken with Ruby 3.3 HOT 1
- differences between macos and linux HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from childprocess.