Job control without a control terminal#149
Merged
Merged
Conversation
POSIX.1-2024 Job control specifications are written in the assumption that a job-control shell may not have a control terminal. The shell should not make an arbitrary terminal its control terminal. To make sure that the shell only opens an existing control terminal, this commit adds O_NOCTTY to the open(2) call for /dev/tty.
The wording of POSIX.1-2024 implies that a shell can perform job control even if it does not have a controlling terminal. This commit allows yash to enable job control even if it does not have a controlling terminal. To do this, the `is_interactive_now` variable is removed, and a new `is_subshell` variable is added. The `doing_job_control_now` macro is modified to check if the shell is a subshell. The `open_ttyfd` function is modified not to disable job control if it fails to open the terminal file. As a side effect, the `-m` option can no longer be used to enable job control in a subshell. This behavior was not documented and probably never used.
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 pull request includes several changes to improve job control handling, update documentation, and make minor code adjustments. The most important changes include enabling job control without a controlling terminal, removing undocumented behavior for job control in subshells, and updating copyright years.
Job control improvements:
exec.c: Changedis_interactive_nowtois_subshellto improve job control handling in subshells.option.c: Updated job control logic to ensure it only runs in interactive shells and not in subshells. [1] [2] [3]option.h: Addedis_subshelland updated macros to reflect the new job control logic. [1] [2]redir.c: Simplified theopen_ttyfdfunction to remove redundant error handling.yash.c: Addedis_subshellflag and updated initialization logic. [1] [2]Documentation updates:
NEWS: Added notes on enabling job control without a controlling terminal and removing undocumented subshell job control behavior. [1] [2]NEWS.ja: Updated Japanese documentation to reflect the same changes. [1] [2]Minor code adjustments:
option.c,option.h,yash.h: Updated copyright years to 2025. [1] [2] [3]Closes #133