changeset 23194:c897282f1ec8 stable

always fork and exec when starting the gui (bug #49609) * main.in.cc (main): Always fork and exec so that we call setsid. (have_controlling_terminal): Delete static function. diff --git a/src/main.in.cc b/src/main.in.cc --- a/src/main.in.cc +++ b/src/main.in.cc @@ -140,25 +140,6 @@ install_signal_handlers (void) gui_driver_set_signal_handler ("SIGXFSZ", gui_driver_sig_handler); } -static bool -have_controlling_terminal (void) -{ - int retval = false; - - const char *ctty = octave_ctermid_wrapper (); - - int fd = octave_open_wrapper (ctty, octave_o_rdwr_wrapper (), 0); - - if (fd >= 0) - { - octave_close_wrapper (fd); - - retval = true; - } - - return retval; -} - #endif static std::string @@ -325,8 +306,17 @@ main (int argc, char **argv) #if defined (HAVE_OCTAVE_QT_GUI) && ! defined (OCTAVE_USE_WINDOWS_API) - if (gui_libs && start_gui && have_controlling_terminal ()) + if (gui_libs && start_gui) { + // Fork and exec when starting the GUI so that we will call + // setsid to give up the controlling terminal (if any) and so that + // the GUI process will be in a separate process group. + // + // The GUI process must be in a separate process group so that we + // can send and interrupt to all child processes when generating + // interrupt signals. See also pthread_thread_manager::interrupt + // in libgui/src/thread-manager.cc and bug #49609. + install_signal_handlers (); gui_pid = octave_fork_wrapper ();
author John W. Eaton <jwe@octave.org>
date Fri, 17 Feb 2017 20:05:35 -0500
parents d222db279c21
children 7cd6ecc578d6 b93e1d29790e
files src/main.in.cc
diffstat 1 files changed, 10 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/src/main.in.cc	Fri Feb 17 17:24:28 2017 +0100
+++ b/src/main.in.cc	Fri Feb 17 20:05:35 2017 -0500
@@ -140,25 +140,6 @@
   gui_driver_set_signal_handler ("SIGXFSZ", gui_driver_sig_handler);
 }
 
-static bool
-have_controlling_terminal (void)
-{
-  int retval = false;
-
-  const char *ctty = octave_ctermid_wrapper ();
-
-  int fd = octave_open_wrapper (ctty, octave_o_rdwr_wrapper (), 0);
-
-  if (fd >= 0)
-    {
-      octave_close_wrapper (fd);
-
-      retval = true;
-    }
-
-  return retval;
-}
-
 #endif
 
 static std::string
@@ -325,8 +306,17 @@
 
 #if defined (HAVE_OCTAVE_QT_GUI) && ! defined (OCTAVE_USE_WINDOWS_API)
 
-  if (gui_libs && start_gui && have_controlling_terminal ())
+  if (gui_libs && start_gui)
     {
+      // Fork and exec when starting the GUI so that we will call
+      // setsid to give up the controlling terminal (if any) and so that
+      // the GUI process will be in a separate process group.
+      //
+      // The GUI process must be in a separate process group so that we
+      // can send and interrupt to all child processes when generating
+      // interrupt signals.  See also pthread_thread_manager::interrupt
+      // in libgui/src/thread-manager.cc and bug #49609.
+
       install_signal_handlers ();
 
       gui_pid = octave_fork_wrapper ();