Repository navigation
WASIX: support process groups and negative PIDs in kill() #7077
Description
Problem
POSIX kill(pid, sig) with a negative pid addresses process groups:
pid == -1: every process the caller may signal (broadcast);ESRCHonly if there are none.pid < -1: every process in group|pid|;ESRCHif that group is empty.
WASIX doesn't support either:
proc_signaltakes an unsignedPid, so wasix-libc'skill(-1234, sig)arrives as4294966062and is looked up as a plain PID. Since fix(wasix): report missing processes from proc_signal #7045, non-positive PIDs (interpreted asi32) are a silent no-op that returns success; before that, all failures were silent.- There are no process groups in the runtime. wasix-libc fakes them per process:
getpgrp()returns__wasilibc_pgrp(default0),setpgid(0, x)storesxlocally, andsetpgid(other, …)andsetsid()fail withEINVAL.
As a result, shell job control can't work: shells put each job in its own group with setpgid and signal it with kill(-pgid, sig) (e.g. forwarding Ctrl-C/SIGINT to a foreground job, or kill -- -$pgid). killpg() and Python's os.killpg are silently ignored as well.
Proposed direction
Move process groups (and sessions, if feasible) from wasix-libc into the runtime:
- Each process in the control plane gets a PGID (and SID), inherited from the parent on spawn and fork; a new process is not its own group leader unless it asks.
- New WASIX syscalls for
setpgid,getpgidandsetsid(andgetsid), with POSIX errors (EPERM/ESRCH/EINVAL,EACCESafter the child has exec'd). - wasix-libc implements
setpgid/getpgid/getpgrp/setsidon top of them, dropping__wasilibc_pgrp. proc_signalinterprets the PID as signed:-1broadcasts to every process in the instance except the caller itself (Linux additionally skips init);< -1signals every process in group|pid|, returningESRCHif it's empty;0is the caller's group (see WASIX: kill(0, sig) should signal the caller's process group #7078).- Ideally, terminal foreground process groups (
tcsetpgrp/tcgetpgrp) follow, so the TTY can deliverSIGINTto the foreground group.
This is a new mechanism spanning the runtime, the WASIX ABI and wasix-libc, so the design should be agreed before implementation. Note that terminated processes are currently never removed from the control plane (#6787), which group lookups would also need to account for.
Acceptance
setpgid/getpgid/setsidbehave per POSIX across spawn and fork.kill(-pgid, sig)reaches every member of the group and only them;kill(-1, sig)reaches every process the caller may signal; empty groups giveESRCH.- Guest tests under
lib/wasix/tests/wasm_tests/signal/, plus a shell job-control smoke test (e.g. bashkill -- -$pgid).
Related: #7045, wasix-org/wasix-libc#144.
Filed by Claude Code (AI agent) on behalf of @Arshia001.
Activity
Arshia001 commentedon Oct 5, 2026
Tracked internally instead; closing here.
Closed by Claude Code (AI agent) on behalf of @Arshia001.