Skip to content

[kernel,cmds] Revise waitpid for stopped jobs, enhance ash, sash & kill signal handling#2523

Merged
ghaerr merged 1 commit intomasterfrom
kill
Dec 12, 2025
Merged

[kernel,cmds] Revise waitpid for stopped jobs, enhance ash, sash & kill signal handling#2523
ghaerr merged 1 commit intomasterfrom
kill

Conversation

@ghaerr
Copy link
Copy Markdown
Owner

@ghaerr ghaerr commented Dec 12, 2025

Revised kernel handling of waitpid for stopped processes; now returns the stopped status just once, per spec. Note that the WUNTRACED flag has to be passed in order to get status of any stopped processes. This simplifies the kernel implementation a bit, since the kernel will never wait for a process to restart when WUNTRACED is passed, regardless of the WNOHANG flag.

The above fix allowed ash to be made to work with its builtin jobs command, which is now useful for displaying all background processes (both asynchronous commands started with '&' as well as any stopped commands). Note that actual "jobs" support is not implemented, so fg is not present. Nonetheless, the jobs enhancement allows a quicker way of finding background jobs without all the details of ps.

The kill command and the sash kill builtin now support many more signal names (rather than signal numbers) to be specified in the command line. This now allows using kill -CONT pid to continue a stopped process, or kill -STOP pid to stop one, for instance. The kill man page is also updated for full details.

Here's an example of running a program a.out which displays X's until stopped by ^Z or interrupted by ^C, and using jobs for displaying processes running under the shell:
Screenshot 2025-12-12 at 1 41 09 PM

Note that stopping jobs that are waiting for input on the same terminal as the shell doesn't work well, and likely won't ever, due to the complications of implementing full job control in both the shell and kernel.

@ghaerr ghaerr merged commit 44d05af into master Dec 12, 2025
1 check passed
@ghaerr ghaerr deleted the kill branch December 12, 2025 22:37
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.

1 participant