# HG changeset patch # User John W. Eaton # Date 1487379935 18000 # Node ID c897282f1ec8f8f9911a1613e01faddacad5b4e7 # Parent d222db279c21a5fa0aa8fe4ea8fc4d7e12960f89 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 (); diff -r d222db279c21 -r c897282f1ec8 src/main.in.cc --- 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 ();