Ignore SIGTSTP (^Z) for run-on-console processes.
authorDavin McCall <davmac@davmac.org>
Thu, 23 Jun 2016 20:25:36 +0000 (21:25 +0100)
committerDavin McCall <davmac@davmac.org>
Thu, 23 Jun 2016 20:25:36 +0000 (21:25 +0100)
We don't want to be job control shell.

src/service.cc

index 490abd962f6e5154db7d061b4ae2e4d312112de2..5b104432ee50999de0d9241c4c1c08a1edb51aeb 100644 (file)
@@ -738,15 +738,17 @@ bool ServiceRecord::start_ps_process(const std::vector<const char *> &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<char **>(args));