From f9f2df999e673a2e3bad6a6de5f8a8c3dfab5c26 Mon Sep 17 00:00:00 2001 From: Luis <42945842+ldiaz94@users.noreply.github.com> Date: Wed, 21 Oct 2026 20:46:10 +0000 Subject: [PATCH] PROPOSALS.md: Sys.setsid, for a daemon --- diff --git a/PROPOSALS.md b/PROPOSALS.md index 215361c..1bb3a64 100644 --- a/PROPOSALS.md +++ b/PROPOSALS.md @@ -1144,3 +1144,25 @@ Met in the question "how difficult to create a simple amd64 unikernel in raz?" (2026-10-17). + +## `Sys.setsid`: a session of a process's own + +Library growth that breaks no program: one procedure, beside `fork`, +in `Sys.raz` (C's `setsid`) and `Sys.linux-x86_64.raz` (system call +112). + + (* A new session and process group, led by this process, with no + controlling terminal: its process id, or minus an errno (-1, + EPERM, if it leads a process group already, as a process just + forked doesn't). *) + proc setsid*: INT; + +A daemon forks, and its child calls `setsid` so that the terminal it +was started from is no longer its own: closing that terminal sends it +no `SIGHUP`, and the terminal's job control doesn't reach it. Without +it, a program can only ignore `SIGHUP`, which `Sys.handle` can't do +(it notes a signal; it doesn't ignore one), and stays in the +terminal's process group, so a Ctrl-C there still reaches it. + +Met in rabble, whose daemon (its `PLAN.md`, from 0.2.0) is started by +the client with `fork` and must outlive the terminal (2026-10-21).