Conversation
POSIX.1-2024 requires that when a foreground job stops in an interactive, job-control shell, the shell discards any remaining commands that were typed but not yet executed, up to and including a next asynchronous list. This is to prevent the user from accidentally executing commands that were intended to be executed after previous commands have completed. Yash did not previously implement this behavior. This commit implements the behavior, but not exactly as specified in POSIX.1-2024. Instead of discarding commands up to and including the next asynchronous list, yash discards all commands that were read but not executed. This is to keep the implementation simple and should be more intuitive for users. See <magicant/yash-rs#478> for more discussion. To implement this behavior, the shell raises an exception when a foreground job stops. The exception is cleared when the shell reads a new command.
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 introduces several changes to improve the handling of suspended jobs in the interactive shell and updates the documentation accordingly. The most important changes include adding new exception handling for suspended jobs, updating documentation for job control, and modifying tests to cover the new behavior.
Improvements to job suspension handling:
exec.c: Added new exceptionE_SUSPENDand functionsraise_suspendandcancel_suspendto handle suspended jobs in the interactive shell. [1] [2]exec.h: Updated header to include declarations forraise_suspendandcancel_suspend.job.c: Modifiedwait_for_jobandwait_for_childfunctions to raiseE_SUSPENDexception when a job is stopped in an interactive shell. [1] [2] [3]yash.c: Added a call tocancel_suspendin theparse_and_execfunction to clear the suspend flag when returning to the command prompt.Documentation updates:
doc/job.txtanddoc/ja/job.txt: Updated job control documentation to describe the new behavior of discarding remaining commands when a job is suspended in an interactive shell. [1] [2]Tests:
tests/job-y.tst: Added a test case to verify that remaining commands are discarded when a command suspends in an interactive shell.Miscellaneous:
NEWSandNEWS.ja: Updated release notes to include the new behavior for handling suspended jobs in the interactive shell. [1] [2]exec.handyash.c. [1] [2]