Skip to content

guest: reset signals in kwtty login before it starts the shell - #7

Open
moon-jam wants to merge 1 commit into
pithings:mainfrom
moon-jam:debian-console-sigint
Open

moon-jam wants to merge 1 commit into
pithings:mainfrom
moon-jam:debian-console-sigint

Conversation

@moon-jam

Copy link
Copy Markdown

Why

On the Debian image, Ctrl-C at the console does not stop the program in the foreground: sleep 20 runs to the end, and python3 -m http.server keeps running.

What changed

kwtty login execs the login shell with the signal dispositions it was started with. login(1) resets SIGINT and SIGQUIT first. Debian's kw-init is a bash script and starts kwtty login as a background command. A non-interactive bash runs background commands with SIGINT and SIGQUIT ignored. The login shell and every program it runs inherit that (SigIgn 0x6), so Ctrl-C stops nothing.

The change touches two files:

  • guest/src/kwtty.c: shell_child() already reset every signal to SIG_DFL and cleared the mask for kwtty serve sessions. That reset is now default_signals(), and login() calls it before execv().
  • test/distro.test.ts: the console test checks that a program started from the console ignores no signal (SigIgn all zero), on every image. The check goes through the console, because kwtty serve already resets signals for vm.exec sessions.

Scope

The Alpine image is not affected, because busybox init resets signals for the programs it starts. kw-init is unchanged. kwtty ships in the base bundle, so the fix reaches the page with the next release's bundle.

Verification

On Linux, pnpm test:distro with the old kwtty fails on Debian only (SigIgn: 0000000000000006). With this change, pnpm test:distro, pnpm test:tty, and pnpm test:api pass.

Thanks for unkernel. Running a real Linux with networking in a browser tab is really impressive. Happy to adjust anything, or feel free to apply it your own way.

kwtty login execs the login shell with the signal dispositions it was
started with, unlike login(1). Debian's kw-init, a bash script, starts
it as a background command, which a non-interactive bash runs with
SIGINT and SIGQUIT ignored, so the shell and every program it ran
inherited that, and Ctrl-C could not stop programs such as sleep or
python3 -m http.server.

Reset every signal to its default and unblock them all, as kwtty serve
already does for its sessions, and check the console's SigIgn on every
image. The Alpine image was not affected, since busybox init resets
signals for the programs it starts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant