From cb1ec995d1877629c938414ddd406d68d06313bd Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Thu, 23 Jun 2016 21:25:36 +0100 Subject: [PATCH] Ignore SIGTSTP (^Z) for run-on-console processes. We don't want to be job control shell. --- src/service.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/service.cc b/src/service.cc index 490abd9..5b10443 100644 --- a/src/service.cc +++ b/src/service.cc @@ -738,15 +738,17 @@ bool ServiceRecord::start_ps_process(const std::vector &cmd, bool } else { // "run on console" - run as a foreground job on the terminal/console device + if (do_set_ctty) { + // Disable suspend (^Z) (and on some systems, delayed suspend / ^Y) + signal(SIGTSTP, SIG_IGN); + + // Become session leader setsid(); ioctl(0, TIOCSCTTY, 0); } setpgid(0,0); tcsetpgrp(0, getpgrp()); - - // TODO disable suspend (^Z)? (via tcsetattr) - // (should be done before TIOCSCTTY) } execvp(exec_arg_parts[0], const_cast(args)); -- 2.25.1