# HG changeset patch # User John W. Eaton # Date 1380909205 14400 # Node ID 1b388d922e6bfba0f62b6ff39f0e895f3b8312fa # Parent 0b3cf264ec2fd7fb8f24ddc68a38e972563863f6 provide --no-fork command line option * octave.cc (no_fork_option): New static varaible. (NO_FORK_OPTION): New macro. (long_opts): Include it in the list. (usage_string, verbose_usage): Update for new --no-fork option. (octave_process_command_line): Handle NO_FORK_OPTION case. * octave-gui.h, octave-gui.cc (octave_start_gui): New arg, fork. Don't call dissociate_terminal if fork is false. * octave.h, octave.cc (octave_fork_gui): New function. * main.cc (main): Use it to pass --no-fork option to gui. diff -r 0b3cf264ec2f -r 1b388d922e6b libgui/src/octave-gui.cc --- a/libgui/src/octave-gui.cc Fri Oct 04 10:35:45 2013 -0700 +++ b/libgui/src/octave-gui.cc Fri Oct 04 13:53:25 2013 -0400 @@ -88,9 +88,10 @@ } int -octave_start_gui (int argc, char *argv[]) +octave_start_gui (int argc, char *argv[], bool fork) { - dissociate_terminal (); + if (fork) + dissociate_terminal (); QApplication application (argc, argv); diff -r 0b3cf264ec2f -r 1b388d922e6b libgui/src/octave-gui.h --- a/libgui/src/octave-gui.h Fri Oct 04 10:35:45 2013 -0700 +++ b/libgui/src/octave-gui.h Fri Oct 04 13:53:25 2013 -0400 @@ -23,6 +23,7 @@ #if !defined (octave_octave_gui_h) #define octave_octave_gui_h 1 -extern OCTGUI_API int octave_start_gui (int argc, char **argv); +extern OCTGUI_API int octave_start_gui (int argc, char **argv, + bool fork = true); #endif diff -r 0b3cf264ec2f -r 1b388d922e6b libinterp/octave.cc --- a/libinterp/octave.cc Fri Oct 04 10:35:45 2013 -0700 +++ b/libinterp/octave.cc Fri Oct 04 13:53:25 2013 -0400 @@ -125,6 +125,10 @@ // (--force-gui) static bool force_gui_option = false; +// If TRUE don't fork when starting the GUI. +// (--no-fork) +static bool no_fork_option = false; + // If TRUE don't start the GUI. // (--no-gui) static bool no_gui_option = false; @@ -159,7 +163,7 @@ [--echo-commands] [--eval CODE] [--exec-path path]\n\ [--force-gui] [--help] [--image-path path]\n\ [--info-file file] [--info-program prog] [--interactive]\n\ - [--line-editing] [--no-gui] [--no-history]\n\ + [--line-editing] [--no-fork] [--no-gui] [--no-history]\n\ [--no-init-file] [--no-init-path] [--no-jit-compiler]\n\ [--no-line-editing] [--no-site-file] [--no-window-system]\n\ [--norc] [-p path] [--path path] [--persist] [--silent]\n\ @@ -194,15 +198,16 @@ #define INFO_PROG_OPTION 8 #define DEBUG_JIT_OPTION 9 #define LINE_EDITING_OPTION 10 -#define NO_GUI_OPTION 11 -#define NO_INIT_FILE_OPTION 12 -#define NO_INIT_PATH_OPTION 13 -#define NO_JIT_COMPILER_OPTION 14 -#define NO_LINE_EDITING_OPTION 15 -#define NO_SITE_FILE_OPTION 16 -#define PERSIST_OPTION 17 -#define TEXI_MACROS_FILE_OPTION 18 -#define TRADITIONAL_OPTION 19 +#define NO_FORK_OPTION 11 +#define NO_GUI_OPTION 12 +#define NO_INIT_FILE_OPTION 13 +#define NO_INIT_PATH_OPTION 14 +#define NO_JIT_COMPILER_OPTION 15 +#define NO_LINE_EDITING_OPTION 16 +#define NO_SITE_FILE_OPTION 17 +#define PERSIST_OPTION 18 +#define TEXI_MACROS_FILE_OPTION 19 +#define TRADITIONAL_OPTION 20 struct option long_opts[] = { { "braindead", no_argument, 0, TRADITIONAL_OPTION }, { "built-in-docstrings-file", required_argument, 0, BUILT_IN_DOCSTRINGS_FILE_OPTION }, @@ -219,6 +224,7 @@ { "info-program", required_argument, 0, INFO_PROG_OPTION }, { "interactive", no_argument, 0, 'i' }, { "line-editing", no_argument, 0, LINE_EDITING_OPTION }, + { "no-fork", no_argument, 0, NO_FORK_OPTION }, { "no-gui", no_argument, 0, NO_GUI_OPTION }, { "no-history", no_argument, 0, 'H' }, { "no-init-file", no_argument, 0, NO_INIT_FILE_OPTION }, @@ -537,6 +543,7 @@ --info-program PROGRAM Use PROGRAM for reading info files.\n\ --interactive, -i Force interactive behavior.\n\ --line-editing Force readline use for command-line editing.\n\ + --no-fork Don't fork when starting the graphical user interface.\n\ --no-gui Disable the graphical user interface.\n\ --no-history, -H Don't save commands to the history list\n\ --no-init-file Don't read the ~/.octaverc or .octaverc files.\n\ @@ -787,6 +794,10 @@ forced_line_editing = true; break; + case NO_FORK_OPTION: + no_fork_option = true; + break; + case NO_GUI_OPTION: no_gui_option = true; break; @@ -1071,6 +1082,12 @@ return start_gui; } +int +octave_fork_gui (void) +{ + return ! no_fork_option; +} + DEFUN (isguirunning, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} isguirunning ()\n\ diff -r 0b3cf264ec2f -r 1b388d922e6b libinterp/octave.h --- a/libinterp/octave.h Fri Oct 04 10:35:45 2013 -0700 +++ b/libinterp/octave.h Fri Oct 04 13:53:25 2013 -0400 @@ -41,6 +41,7 @@ extern OCTINTERP_API int octave_embedded; extern OCTINTERP_API int octave_starting_gui (void); +extern OCTINTERP_API int octave_fork_gui (void); #ifdef __cplusplus } diff -r 0b3cf264ec2f -r 1b388d922e6b src/main.cc --- a/src/main.cc Fri Oct 04 10:35:45 2013 -0700 +++ b/src/main.cc Fri Oct 04 13:53:25 2013 -0400 @@ -41,7 +41,7 @@ install_defaults (); if (octave_starting_gui ()) - retval = octave_start_gui (argc, argv); + retval = octave_start_gui (argc, argv, octave_fork_gui ()); else { octave_initialize_interpreter (argc, argv, 0);