Hello Piotr 👋
This is more of a feature request, as I haven't used tty-command yet and experienced an issue with it. However, I would like to suggest a reliability improvement for tty-command, which is to write to stdin and read from stdout/stderr simultaneously without threads, using the nonblocking APIs.
Let me explain. Some MiniMagick users have been experiencing deadlocks with the shell command execution. MiniMagick uses Open3.capture3, which spawns threads for reading stdout and stderr. The guess was that somewhere during thread context switching Ruby thinks it's in a deadlock, even though stdout and stderr pipes are being emptied.
The Basecamp team made pull request to use posix-spawn's simultaneous reading and writing from streams, which you can find in POSIX::Spawn::Child#read_and_write. That change fixed deadlocks for Basecamp, so I think it might fix potential deadlocks in tty-command. A bonus is that no additional threads need to be spawned, which is always nice.
What do you think?
Hello Piotr 👋
This is more of a feature request, as I haven't used
tty-commandyet and experienced an issue with it. However, I would like to suggest a reliability improvement fortty-command, which is to write to stdin and read from stdout/stderr simultaneously without threads, using the nonblocking APIs.Let me explain. Some MiniMagick users have been experiencing deadlocks with the shell command execution. MiniMagick uses
Open3.capture3, which spawns threads for reading stdout and stderr. The guess was that somewhere during thread context switching Ruby thinks it's in a deadlock, even though stdout and stderr pipes are being emptied.The Basecamp team made pull request to use
posix-spawn's simultaneous reading and writing from streams, which you can find inPOSIX::Spawn::Child#read_and_write. That change fixed deadlocks for Basecamp, so I think it might fix potential deadlocks intty-command. A bonus is that no additional threads need to be spawned, which is always nice.What do you think?