From 5cdbd57875b268ddf0fb6949e4918a459aab2313 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Fri, 13 Jan 2017 07:48:00 +0100 Subject: [PATCH] reboot: Ignore SIGTERM at halt/poweroff We want to emulate the behavior of the reboot() syscall on success. Primarily for a coherency/symmetry, but also to prevent printing a new shell prompt in the middle of system shutdown messages. Signed-off-by: Joachim Nilsson --- reboot.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/reboot.c b/reboot.c index a5e5628e..384b2a16 100644 --- a/reboot.c +++ b/reboot.c @@ -85,6 +85,11 @@ static void transform(char *nm) } } +static void sig(int signo) +{ + (void)signo; /* NOP */ +} + static int usage(int rc) { fprintf(stderr, "Usage: %s [OPTIONS]\n\n" @@ -144,6 +149,9 @@ int main(int argc, char *argv[]) /* Check for any overrides */ transform(NULL); + /* Catch and ignore SIGTERM on halt/poweroff */ + signal(SIGTERM, sig); + if (force) { switch (cmd) { case CMD_REBOOT: