From: Davin McCall <davmac@davmac.org> Date: Sat, 27 Jul 2019 07:03:41 +0000 (+1000) Subject: Don't add console watcher if not PID 1. X-Git-Tag: v0.6.1~2 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=8c6acc1371eace16aac319e0a9cdefe96f4b7537;p=oweals%2Fdinit.git Don't add console watcher if not PID 1. If not PID 1, we don't need to ask for console input. Adding a watcher fails if we don't have a (suitable) stdin, eg FreeBSD shell if dinit is run in background. --- diff --git a/src/dinit.cc b/src/dinit.cc index 2481032..0c50f47 100644 --- a/src/dinit.cc +++ b/src/dinit.cc @@ -388,12 +388,12 @@ int dinit_main(int argc, char **argv) sigint_watcher.add_watch(event_loop, SIGINT); sigterm_watcher.add_watch(event_loop, SIGTERM); - console_input_io.add_watch(event_loop, STDIN_FILENO, dasynq::IN_EVENTS, false); if (am_pid_one) { - // PID 1: SIGQUIT exec's shutdown + // PID 1: we may ask for console input; SIGQUIT exec's shutdown + console_input_io.add_watch(event_loop, STDIN_FILENO, dasynq::IN_EVENTS, false); sigquit_watcher.add_watch(event_loop, SIGQUIT); - // As a user process, we instead just let SIGQUIT perform the default action. + // (If not PID 1, we instead just let SIGQUIT perform the default action.) } // Try to open control socket (may fail due to readonly filesystem)