schinit: a launchd-shaped process 1
Milestone 1 of three: manifests, RunAtLoad, KeepAlive with throttling,
and reaping. Replaces the hardcoded fork-a-shell loop in cmd/init, which
stays in the tree for now.
Jobs are sectioned key=value files in /etc/schinit/*.job, kept in the
repo under etc/ and installed into the sysroot -- sysroot/ is generated
and gitignored, so anything written only there is lost on a fresh clone,
which is already true of /etc/passwd and should not become true of the
boot configuration. Unknown keys and sections are ignored rather than
fatal: a manifest written for a newer schinit must not stop this one
booting the machine.
Socket sections are parsed and recorded but not yet held. That is
milestone 2 and it is the whole reason for copying launchd rather than
sysvinit -- the supervisor holds the listener and starts the job on first
connect, which inverts the dependency graph and makes runlevels a
non-concept. The key exists now so manifests need not change later.
getdents64 is exposed to userland for this. The kernel has had it since
the Linux ABI landed, but nothing declared it in user.h or lib/usys.S, so
first-party programs had no way to list a directory at all.
Two things found by testing rather than reasoning:
- setsid() gives a job its own session, and a session has no
controlling terminal. The console then delivers input only to the
foreground process group it tracks, so the shell came up, echoed
every keystroke through the line discipline, and executed none of
them -- indistinguishable from a hung shell. ControllingTerminal=yes
claims it with TIOCSCTTY/TIOCSPGRP; off by default, since a daemon
has no business seizing the console.
- the first bootstrap() dropped /dev/input/event0-1 and most of /proc,
because it was transcribed from the part of the old init that had
been read rather than all of it. -Evdev caught it.
build/usbstick.img is built by `all` now: without it QEMU refuses the
-drive and the entire -Usb run produces no output, which reads as a
broken USB driver.
Seven suites green: base 27, Tty 51, Ps 32, Sock 64, Fb 36, Usb 31,
Evdev 29. make schfs-check passes.
This commit is contained in:
parent
08a1a9033a
commit
baede13847
10 changed files with 664 additions and 7 deletions
25
etc/schinit/console-shell.job
Normal file
25
etc/schinit/console-shell.job
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
# The interactive shell on the system console.
|
||||
#
|
||||
# In launchd terms this is a RunAtLoad + KeepAlive daemon: started when
|
||||
# schinit loads, and restarted whenever it exits -- which for a shell is
|
||||
# every time someone types `exit`.
|
||||
|
||||
Label = os.schos.console-shell
|
||||
Program = /bin/sh
|
||||
Args = sh
|
||||
RunAtLoad = yes
|
||||
KeepAlive = yes
|
||||
|
||||
# This job reads the console, so it has to own it: schinit puts every job in
|
||||
# its own session, and a session with no controlling terminal is not delivered
|
||||
# terminal input at all. Without this the shell echoes and executes nothing.
|
||||
ControllingTerminal = yes
|
||||
|
||||
StandardIn = /dev/console
|
||||
StandardOut = /dev/console
|
||||
StandardError = /dev/console
|
||||
|
||||
# Seconds between respawns. Guards against a shell that dies instantly
|
||||
# taking the machine with it; launchd calls this ThrottleInterval and
|
||||
# defaults to 10. One is enough for a shell someone just exited on purpose.
|
||||
ThrottleInterval = 1
|
||||
Loading…
Reference in a new issue