Skip to content

WASIX: support process groups and negative PIDs in kill() #7077

Closed as not planned

Description

@Arshia001

Problem

POSIX kill(pid, sig) with a negative pid addresses process groups:

  • pid == -1: every process the caller may signal (broadcast); ESRCH only if there are none.
  • pid < -1: every process in group |pid|; ESRCH if that group is empty.

WASIX doesn't support either:

  • proc_signal takes an unsigned Pid, so wasix-libc's kill(-1234, sig) arrives as 4294966062 and is looked up as a plain PID. Since fix(wasix): report missing processes from proc_signal #7045, non-positive PIDs (interpreted as i32) 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 (default 0), setpgid(0, x) stores x locally, and setpgid(other, …) and setsid() fail with EINVAL.

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:

  1. 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.
  2. New WASIX syscalls for setpgid, getpgid and setsid (and getsid), with POSIX errors (EPERM / ESRCH / EINVAL, EACCES after the child has exec'd).
  3. wasix-libc implements setpgid/getpgid/getpgrp/setsid on top of them, dropping __wasilibc_pgrp.
  4. proc_signal interprets the PID as signed: -1 broadcasts to every process in the instance except the caller itself (Linux additionally skips init); < -1 signals every process in group |pid|, returning ESRCH if it's empty; 0 is the caller's group (see WASIX: kill(0, sig) should signal the caller's process group #7078).
  5. Ideally, terminal foreground process groups (tcsetpgrp/tcgetpgrp) follow, so the TTY can deliver SIGINT to 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/setsid behave 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 give ESRCH.
  • Guest tests under lib/wasix/tests/wasm_tests/signal/, plus a shell job-control smoke test (e.g. bash kill -- -$pgid).

Related: #7045, wasix-org/wasix-libc#144.

Filed by Claude Code (AI agent) on behalf of @Arshia001.

Activity

  1. Arshia001 commented on Oct 5, 2026

    @Arshia001
    ContributorAuthor

    Tracked internally instead; closing here.

    Closed by Claude Code (AI agent) on behalf of @Arshia001.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions