-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[Process] Documented setTty and setPty methods #14769
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
versionadded directive needed?
No, pty was introduced in 2.5 and tty even before that. This is one of the oldest undocumented features |
b28d31a
to
1b5e8dc
Compare
All examples above show that your program has control over the input of a | ||
process (using ``setInput()``) and the output from that process (using | ||
``getOutput()``). The Process component has two special modes that tweak | ||
the relationship between your program and the process: teletype (tty) and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm nitpicking, but this is slightly confusing to me:
the relationship between your program and the process
"your program" is the Symfony application ... or the code of my Symfony app which is using Symfony's Process class?
"the process" is the code using Symfony's Process class ... or is it the process being executed by the operating system?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I'm not sure what you mean. As tty/pty replaces input/output with the input/output of the process, it can only be run as a command (running it in e.g. a controller produces an error). So "your program" is the code of the Symfony app which uses the Process class
// to read or modify the output from the process! | ||
dump($process->getOutput()); // null | ||
|
||
In PTY mode, your program behaves as a terminal for the process instead of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TTY
mode is very clear to me thanks to your previous explanation and example ... but PTY is not the same case. I don't fully understand why/when I should use PTY instead of the default Symfony behavior (which is no TTY and no PTY). Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the big issue is that I can't come up with a use-case for PTY (i.e. I also don't fully understand PTY). Even more, I've searched github for setPty(true)
and didn't find anything useful, nor did googling for articles about PHP's own pty support.
So what do you think about significantly shortening this paragraph instead? I think PTY will only be used by process experts, we mainly need to document it to tell them "we support those too". So mentioning setPty()
somewhere is probably enough (?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After reading some resources about this, I liked this simplification that I read in a StackOverflow answer:
- TTY is a real console, like the one you use in your OS
- PTY is a fake console, like the one you use when doing SSH into another machine
Can we run ssh
via Symfony's Process when using PTY?
Although it's true that we're missing an example for PTY ... let's merge this because it will help readers and it will improve existing docs. Thanks Wouter! |
Fixes #6188
I had lots of trouble documenting these methods, as they require quite a bit of knowledge about tty/pty to understand. Please review this and let me know if things are unclear 🙏 (or if things are a bit too much in-depth for a Symfony doc)
Also, I can't come up with a simple example for
setPty()
.