]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
cfdisk: handle SIGHUP to avoid busy-loop on terminal loss
authorKarel Zak <kzak@redhat.com>
Wed, 24 Jun 2026 11:22:12 +0000 (13:22 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 24 Jun 2026 11:22:12 +0000 (13:22 +0200)
When the controlling terminal disappears (e.g., a web terminal
session is closed), the kernel sends SIGHUP. Without handling it,
cfdisk's getch() returns ERR in a tight loop, causing 100% CPU
usage indefinitely.

Register SIGHUP with the existing sig_handler_die() so that all
loops exit via the existing sig_die checks.

Addresses: https://github.com/util-linux/util-linux/pull/4385

Signed-off-by: Karel Zak <kzak@redhat.com>
disk-utils/cfdisk.c

index 023f28161c9bf8180b7c04e8727131d453faa91c..3bc16e8feaa88a825d689e22526ee89b420d3b62 100644 (file)
@@ -956,6 +956,7 @@ static int ui_init(struct cfdisk *cf __attribute__((__unused__)))
        sa.sa_handler = sig_handler_die;
        sigaction(SIGINT, &sa, NULL);
        sigaction(SIGTERM, &sa, NULL);
+       sigaction(SIGHUP, &sa, NULL);
 
        sa.sa_handler = sig_handler_resize;
        sigaction(SIGWINCH, &sa, NULL);