Subject: "herd restart term-tty2" caused *all* processes to be killed

From: Mark H Weaver <[email-masked]>
Date: Sun, 02 Dec 2018 20:16:29 -0500

After killing a Wayland 'gnome-session' that I had launched from the
command-line on tty2, the login prompt did not return as it normally
does.

I decided to try "herd restart term-tty2" to see if that would help.
That turned out to be a serious mistake.  It caused TERM to be sent to
all processes, most filesystems to be unmounted, and many (all?) core
services to be stopped.  This left my system in a unusuable state,
besides being able to switch between otherwise unresponsive text virtual
terminals and issue SysRq commands.

I took a picture of the display before resetting the machine.
Fortunately I always use text virtual terminals for my root shells.
Here's a hand-typed approximation of what shepherd printed to the
console:

--8<---------------cut here---------------start------------->8---
root@jojen ~# herd restart term-tty2
[200060.46xxxx] shepherd[1]: Service term-tty4 has been stopped.
[200060.46xxxx] shepherd[1]: Service nscd has been stopped.
[200060.47xxxx] shepherd[1]: Service guix-daemon has been stopped.
[200060.47xxxx] shepherd[1]: Service term-tty2 has been stopped.
[200060.47xxxx] shepherd[1]: Service console-font-tty1 has been stopped.
[200060.48xxxx] shepherd[1]: Service term-tty1 has been stopped.
[200060.48xxxx] shepherd[1]: Service console-font-tty5 has been stopped.
[200060.48xxxx] shepherd[1]: Service term-tty5 has been stopped.
[200060.49xxxx] shepherd[1]: sending all processes the TERM signal
[200064.81xxxx] shepherd[1]: all processes have been terminated
[200064.81xxxx] shepherd[1]: Service user-processes has been stopped.
[200064.82xxxx] shepherd[1]: Service urandom-seed has been stopped.
[200064.82xxxx] shepherd[1]: Service file-systems has been stopped.
[200064.83xxxx] shepherd[1]: Service file-system-/dev/pts has been stopped.
[200064.84xxxx] shepherd[1]: Service file-system-/sys/fs/cgroup/blkio has been stopped.
[200064.86xxxx] shepherd[1]: Service file-system-/gnu/store has been stopped.
[200064.88xxxx] shepherd[1]: Service file-system-/sys/fs/cgroup/freezer has been stopped.
[200064.90xxxx] shepherd[1]: Service file-system-/run/systemd has been stopped.
[200064.91xxxx] shepherd[1]: Service file-system-/sys/fs/cgroup/cpuset has been stopped.
[200064.93xxxx] shepherd[1]: Service file-system-/sys/fs/cgroup/cpuacct has been stopped.
[200064.95xxxx] shepherd[1]: Service file-system-/sys/fs/cgroup/devices has been stopped.
[200064.96xxxx] shepherd[1]: Service file-system-/sys/fs/cgroup/perf_event has been stopped.
[200064.98xxxx] shepherd[1]: Service file-system-/run/user has been stopped.
[200065.00xxxx] shepherd[1]: Service file-system-/dev/shm has been stopped.
[200065.01xxxx] shepherd[1]: Service file-system-/sys/fs/cgroup/memory has been stopped.
[200065.03xxxx] shepherd[1]: Service file-system-/sys/fs/cgroup/elogind has been stopped.
[200065.05xxxx] shepherd[1]: Service file-system-/sys/fs/cgroup/cpu has been stopped.
[200065.06xxxx] shepherd[1]: Service file-system-/sys/fs/cgroup has been stopped.
[200065.06xxxx] shepherd[1]: system-error("kill" "~A" ("No such process") (3))
[200065.06xxxx] shepherd[1]: Service udev has been stopped.
[200065.06xxxx] shepherd[1]: Service virtual-terminal has been stopped.
[200065.19xxxx] shepherd[1]: closing log
[200065.23xxxx] BTRFS info (device dm-0): disk space caching is enabled
--8<---------------cut here---------------end--------------->8---

The 'xxxx' are of course more digits that I was too lazy to type.

I would not have expected 'term-tty2' to have many dependents, except
possibly for 'console-font-tty2'.  It was a great surprise that
restarting it caused so many other core services to be stopped.

Any idea what went wrong here?

       Mark