| | @@ -1144,3 +1144,25 @@ |
| 1144 | 1144 | |
| 1145 | 1145 | Met in the question "how difficult to create a simple amd64 unikernel |
| 1146 | 1146 | in raz?" (2026-10-17). |
| 1147 | + |
| 1148 | +## `Sys.setsid`: a session of a process's own |
| 1149 | + |
| 1150 | +Library growth that breaks no program: one procedure, beside `fork`, |
| 1151 | +in `Sys.raz` (C's `setsid`) and `Sys.linux-x86_64.raz` (system call |
| 1152 | +112). |
| 1153 | + |
| 1154 | + (* A new session and process group, led by this process, with no |
| 1155 | + controlling terminal: its process id, or minus an errno (-1, |
| 1156 | + EPERM, if it leads a process group already, as a process just |
| 1157 | + forked doesn't). *) |
| 1158 | + proc setsid*: INT; |
| 1159 | + |
| 1160 | +A daemon forks, and its child calls `setsid` so that the terminal it |
| 1161 | +was started from is no longer its own: closing that terminal sends it |
| 1162 | +no `SIGHUP`, and the terminal's job control doesn't reach it. Without |
| 1163 | +it, a program can only ignore `SIGHUP`, which `Sys.handle` can't do |
| 1164 | +(it notes a signal; it doesn't ignore one), and stays in the |
| 1165 | +terminal's process group, so a Ctrl-C there still reaches it. |
| 1166 | + |
| 1167 | +Met in rabble, whose daemon (its `PLAN.md`, from 0.2.0) is started by |
| 1168 | +the client with `fork` and must outlive the terminal (2026-10-21). |