-
Notifications
You must be signed in to change notification settings - Fork 2
Implement PTY to handle both stdout, stderr with redirects #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Doesn't work on Windows because it uses |
I may need to fork the project or just start anew. Their repo site is giving an HTTP 502. In any case, the question remains how to:
Considering https://www.man7.org/linux/man-pages/man3/forkpty.3.html and a .NET project I found at https://github.com/microsoft/vs-pty.net, maybe I'm overthinking this. If I start a process under a PTY, I don't need to actually handle |
This does actually work - well, almost. I still can't redirect stdout and/or stderr like I can with Works: op run -- target/release/examples/printenv 2> /dev/null Doesn't work (doesn't redirect): akv run -- target/release/examples/printenv 2> /dev/null |
If passed to `/bin/sh -c`, you can make redirects work if you put the whole command in quotes e.g., `akv run -- 'printenv 2> /dev/null'` but that's still pretty hacky.
Here's the winner: check first if either or both of stdout or stderr are redirected. Whichever are, redirect the `Command` streams accordingly.
It almost works but the read end isn't closing when the process terminates like it does when using `pty-process` despite doing basically the same thing.
...or at least `not(windows)`.
Added a custom implementation of the Debug trait for the Pty struct to allow for better formatting of the inner structure. This enhances the debugging experience by providing clearer output.
This feels pretty hacky, though. I effectively need to tie the lifetime of the pty fd to the child process, but it seems unless I write my own `Command` or `Child` wrapper I can't really do that.
Mostly solves the Windows problem, though I still need to refactor POSIX. But even though this flow is recommended, I'm still getting a heap corruption error most times. Can't figure out what's corrupt. Should check AppVerifier.
Fixes heap corruption issue on Windows
Got this working with my own PTY implementation. Properly detects and shows colors, properly interleaves, and properly redirects stdout and/or stderr. |
No description provided.