yash-rs icon indicating copy to clipboard operation
yash-rs copied to clipboard

Saving and restoring the terminal state of a suspended job

Open magicant opened this issue 8 months ago • 0 comments
trafficstars

POSIX.1-2024 job control specifications require the shell to save and restore the terminal state:

When a suspended job is created as a result of a foreground job being stopped, it shall be assigned a job number, and an interactive shell shall write, and a non-interactive shell may write, a message to standard error, formatted as described by the jobs utility (without the -l option) for a suspended job. ... If the shell is interactive, it shall save the terminal settings before changing them to the settings it needs to read further commands.

If the fg utility is used from an interactive shell to bring into the foreground a suspended job that was created from a foreground job, before it sends the SIGCONT signal the fg utility shall restore the terminal settings to the ones that the shell saved when the job was suspended.

The shell needs to save the terminal state when a foreground job suspends and restore it before resuming the job.

See also #299.

magicant avatar Mar 12 '25 13:03 magicant