Subprocesses
(sigil process) runs external commands and provides access to their standard streams and exit status.
Linux process handles
process-open-handle takes a positive PID and returns a handle to the live process or #f if that process has exited or the PID does not exist. Use call-with-process-handle with the PID and a procedure to close the handle on scope exit, including exceptions and continuation exits. The procedure receives the handle and is called only if the open succeeds.
process-handle-identity returns an association list with pid, start-time and pid-namespace keys. The start time is in Linux clock ticks since boot and the namespace is the inode number of the process's PID namespace. The snapshot remains available after the process exits, until the handle closes.
process-handle-send-signal! takes a handle and a signal name or number. It returns #t on success and #f if the process has exited. The kernel receives the handle's descriptor, so PID reuse cannot redirect the signal. Other failures, including a closed handle or unavailable pidfds, raise an io-error. Opening a handle requires Linux openat2, a procfs mount for the caller's PID namespace, and permission to read the process's identity. Identity lookup refuses substituted mounts below procfs.
Use process-spawn with handle: #t to capture the handle before the child execs, even for a command that exits immediately. process-take-handle! transfers that handle out of the process object once and returns #f if the object has no handle to transfer. Close the transferred handle with process-handle-close!. Closing a handle never changes the child's wait status.
Explicit descriptor inheritance on Linux
Pass pass-fds: a list of (child-fd . source) pairs to control the child's descriptor table. Sources can be open directory or entry handles from (sigil fs anchored) or open ports backed by OS descriptors. The child receives duplicates with the same access mode. The parent retains ownership of the sources and can close them after spawn. A port's userspace buffering stays in the parent. Flush output before passing a port if the child needs to see data still buffered there.
Specify '() for a child that needs only its configured standard streams. A supplied map causes the child to close all unlisted descriptors, including ones opened during the parent-to-fork interval. The child blocks signals during setup, resets caught host handlers to their default actions, and restores the exec-time mask after the descriptor sweep. This requires Linux close_range. An unavailable syscall is a child setup failure reported through %process-spawn-error and exit status 126. Omitting pass-fds: keeps the legacy inheritance behavior.
stdin:, stdout: and stderr: each accept 'capture or 'inherit. Capture is the default and exposes the parent side through process-stdin, process-stdout or process-stderr. Inheritance uses the corresponding parent OS stream and produces no parent-side process port. A map entry for descriptor 0, 1 or 2 can supply that stream instead. Each stream may have one configuration, including the existing in:, out: and err: redirections.
(process-spawn "command"
pass-fds: (list (cons 7 directory))
stdin: 'inherit
stderr: 'inherit
child-signals: '((int . ignore) (quit . ignore)))child-signals: accepts int, quit, term and hup, with a disposition of ignore, default or inherit. The explicit ignore and default dispositions also unblock that signal in the child. Inherited signals follow the operating system's exec rules, including its handling of installed callbacks and the inherited signal mask.
Parent death on Linux
die-with-parent: #t asks Linux to deliver SIGKILL to the child when the spawning parent thread exits. Plain, PTY, and pipe spawn check whether the kernel accepted the request and abort child setup if it failed. The child checks for reparenting after arming the signal to cover a parent that died during startup.
With this option, PTY spawn defers cancellation of the creating thread through the arming acknowledgment and parent-side cleanup. Plain and pipe spawn defer it through the exec-status read and cleanup. A child can block before exec even after arming the signal. For example, plain spawn with in: set to a FIFO can wait for a writer. A cancellation request stays pending while the FIFO waits.
After spawn returns, exiting the creating thread kills the child even if other threads in the parent process remain alive. To tie the child's lifetime to a multithreaded process, spawn it from a thread that lives for the lifetime of that process.
The setting survives ordinary exec. Linux clears it when the child's effective or filesystem UID or GID changes, or when the child executes a set-user-ID, set-group-ID, or file-capability program. A child that crosses one of those boundaries can survive the death of its original parent.