Skip to content

Job control without a control terminal#149

Merged
magicant merged 2 commits into
trunkfrom
job-control-w/o-tty
Mar 30, 2025
Merged

Job control without a control terminal#149
magicant merged 2 commits into
trunkfrom
job-control-w/o-tty

Conversation

@magicant

Copy link
Copy Markdown
Owner

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: Changed is_interactive_now to is_subshell to 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: Added is_subshell and updated macros to reflect the new job control logic. [1] [2]
  • redir.c: Simplified the open_ttyfd function to remove redundant error handling.
  • yash.c: Added is_subshell flag 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

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.
@magicant magicant added this to the 2.59 milestone Mar 30, 2025
@magicant magicant self-assigned this Mar 30, 2025
@magicant
magicant merged commit 5f55049 into trunk Mar 30, 2025
@magicant
magicant deleted the job-control-w/o-tty branch March 30, 2025 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allowing job control without a control terminal

1 participant