Open
Conversation
tbodt
reviewed
Aug 31, 2024
| lock(&tty->lock); | ||
| if (tty->hung_up || pty_is_half_closed_master(tty)) { | ||
| unlock(&pids_lock); | ||
| err = -1; |
| // hang_up on the pty master. But the session leader may have a | ||
| // reference, and the pty master always has a reference. | ||
| if (tty->refcount - 1 == (tty->session ? 2 : 1)) { | ||
| tty->pty.other->hung_up = false; |
| // If userland's reference count on the pty slave is now 1, clear | ||
| // hang_up on the pty master. But the session leader may have a | ||
| // reference, and the pty master always has a reference. | ||
| if (tty->refcount - 1 == (tty->session ? 2 : 1)) { |
Member
There was a problem hiding this comment.
I found this check a bit unsettling in the last PR but figured it could be fixed later. Seeing it again, I'm thinking much the same thing... Ideally we would define explicitly which references count for this and which ones don't, and with that knowledge the likely solution is to create a second refcount field for tracking just those.
Xcopz1
approved these changes
Sep 5, 2024
enkhjargal
approved these changes
Sep 20, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This should fix the problem brought up by @francoisvignon in my original work on #2387. At the time I wrote that I hadn't even thought about pty masters allowing serial reuse of the pty slave, and so it worked more like physical serial devices, where you don't want them to work after the modem hangs up.
This is definitely one of those less well documented and supported bits of functionality in ptys (there are many). But it seems like a good idea to support this because Linux does.