Skip to content

[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

Merged
merged 1 commit into from
Apr 14, 2021

Conversation

wouterj
Copy link
Member

@wouterj wouterj commented Jan 2, 2021

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().

Copy link
Contributor

@OskarStark OskarStark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

versionadded directive needed?

@wouterj
Copy link
Member Author

wouterj commented Jan 2, 2021

No, pty was introduced in 2.5 and tty even before that. This is one of the oldest undocumented features

@wouterj wouterj force-pushed the issue-6188/process-tty-pty branch from b28d31a to 1b5e8dc Compare January 3, 2021 12:06
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
Copy link
Member

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?

Copy link
Member Author

@wouterj wouterj Jan 11, 2021

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
Copy link
Member

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!

Copy link
Member Author

@wouterj wouterj Jan 11, 2021

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 (?)

Copy link
Member

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?

@wouterj wouterj added Process and removed Console labels Jan 4, 2021
@carsonbot carsonbot changed the title [Console] Documented setTty and setPty methods [Process] [Console] Documented setTty and setPty methods Jan 4, 2021
@wouterj wouterj changed the title [Process] [Console] Documented setTty and setPty methods [Process] Documented setTty and setPty methods Jan 5, 2021
@javiereguiluz
Copy link
Member

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!

@javiereguiluz javiereguiluz merged commit 7849ede into symfony:4.4 Apr 14, 2021
@wouterj wouterj deleted the issue-6188/process-tty-pty branch April 14, 2021 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants