backend,termstatus: Unify foreground/background detection#5493
Merged
Conversation
4 tasks
Member
|
I see you've also noticed the bug in #5358 . While starting to fix it, I got a bit carried away and refactored most terminal-related code into a separate package: #5494 . My suggestion would be to drop the |
561c699 to
884ae8c
Compare
PR restic#5358 reintroduced a version of the TIOCGPGRP ioctl call that works on all Unix platforms except Linux, due to a bug/inconsistency in x/sys/unix. This commit fixes that by introducing termstatus.Tcgetpgrp. It also introduces termstatus.Getpgrp and termstatus.Tcsetpgrp to deal with the different signature of unix.Getpgrp in Solaris vs. all other Unix platforms and an int-overflowing constant on AIX, so that some AIX/Solaris-specific code can be removed elsewhere and foreground/background detection is done the same everywhere except on Windows.
MichaelEischer
approved these changes
Sep 8, 2025
MichaelEischer
left a comment
Member
There was a problem hiding this comment.
LGTM. Thanks for fixing this once again!
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.
What does this PR change? What problem does it solve?
PR #5358 reintroduced a version of the TIOCGPGRP ioctl call that works on all Unix platforms except Linux, due to a bug/inconsistency in x/sys/unix. This commit fixes that by introducing termstatus.Tcgetpgrp.
It also introduces termstatus.Getpgrp to deal with the different signature of unix.Getpgrp in Solaris vs. all other Unix platforms, so that some AIX/Solaris-specific code can be removed elsewhere and foreground/background detection is done the same everywhere except on Windows.
I tested this on Linux and checked that AIX, Darwin, FreeBSD and Solaris continue to compile.
Was the change previously discussed in an issue or on the forum?
The bug in x/sys/unix was first noticed in #4223, which was fixed by #4339.
Checklist
changelog/unreleased/that describes the changes for our users (see template).