From e518ab667b21e1013077746fce1f28ffb154c0f6 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Wed, 29 Nov 2023 19:49:51 +0000 Subject: [PATCH] make job control work in console shell --- modules/s6/default.nix | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/modules/s6/default.nix b/modules/s6/default.nix index a6775fb..cd05de7 100644 --- a/modules/s6/default.nix +++ b/modules/s6/default.nix @@ -81,14 +81,22 @@ let }; getty = dir { run = { + # We can't run a useful shell on /dev/console because + # /dev/console is not allowed to be the controlling + # tty of any process, which means ^C ^Z etc don't work. + # So we work out what the *actual* console device is + # using sysfs and open our shell there instead. file = '' - #!${execline}/bin/execlineb -P - ${execline}/bin/redirfd -w 2 /dev/console - ${execline}/bin/fdmove -c 1 2 - ${execline}/bin/redirfd -r 0 /dev/console - ${execline}/bin/cd / - /bin/ash -l - ''; + #!${execline}/bin/execlineb -P + ${execline}/bin/cd / + redirfd -r 0 /sys/devices/virtual/tty/console/active + withstdinas CONSOLETTY + importas CONSOLETTY CONSOLETTY + redirfd -w 2 /dev/''${CONSOLETTY} + fdmove -c 1 2 + redirfd -r 0 /dev/''${CONSOLETTY} + /bin/ash -l + ''; mode = "0755"; }; down-signal = {