annotate src/main.in.cc @ 30192:8c8031be8072

Windows: Don't get pointers to C strings while vector is still unstable. * src/main-cli.cc, src/main-gui.cc, src/main.in.cc, src/octave-config.in.cc, src/octave-svgconvert.cc: The memory used by a vector is not guaranteed to be stable when elements are added with push_back. Wait until vector is complete before getting the pointers to the corresponding C strings.
author Markus Mützel <markus.muetzel@gmx.de>
date Thu, 16 Sep 2021 21:51:03 +0200
parents 218716316e62
children e1b0ed07895b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1 // %NO_EDIT_WARNING%
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
3 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
29358
0a5b15007766 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 29191
diff changeset
5 // Copyright (C) 2012-2021 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
25 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
26 ////////////////////////////////////////////////////////////////////////
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 // NOTE: This program is supposed to be a small wrapper that exists
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29 // primarily to give up the controlling TTY and then exec Octave with
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30 // its GUI. It may also execute Octave without the GUI or the command
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31 // line version of Octave that is not linked with GUI libraries. So
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 // that it remains small, it should NOT depend on or be linked with
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33 // liboctave or libinterp.
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21440
diff changeset
35 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21286
diff changeset
36 # include "config.h"
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 #endif
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39 #include <cstdlib>
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40 #include <cstring>
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42 #include <algorithm>
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 #include <iostream>
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
44 #include <string>
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
45
29540
b6f80b1d448f Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29510
diff changeset
46 #if defined (OCTAVE_USE_WINDOWS_API) && defined (_UNICODE)
b6f80b1d448f Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29510
diff changeset
47 # include <vector>
b6f80b1d448f Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29510
diff changeset
48 # include <locale>
b6f80b1d448f Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29510
diff changeset
49 # include <codecvt>
b6f80b1d448f Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29510
diff changeset
50 #endif
b6f80b1d448f Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29510
diff changeset
51
29237
1af06a145d40 Un-set API flags when using functions without linking to shared library (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29191
diff changeset
52 // We are linking against static libs so do not decorate with dllimport.
1af06a145d40 Un-set API flags when using functions without linking to shared library (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29191
diff changeset
53 // FIXME: This should be done by the build system.
1af06a145d40 Un-set API flags when using functions without linking to shared library (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29191
diff changeset
54 #undef OCTAVE_API
1af06a145d40 Un-set API flags when using functions without linking to shared library (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29191
diff changeset
55 #define OCTAVE_API
21927
6f62bd248919 use wrapper functions for mkoctfile and main
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
56 #include "fcntl-wrappers.h"
29898
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
57 #include "getopt-wrapper.h"
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21927
diff changeset
58 #include "signal-wrappers.h"
21927
6f62bd248919 use wrapper functions for mkoctfile and main
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
59 #include "unistd-wrappers.h"
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21783
diff changeset
60 #include "wait-wrappers.h"
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21783
diff changeset
61
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21440
diff changeset
62 #if ! defined (OCTAVE_VERSION)
21202
f7121e111991 maint: indent #ifdef blocks in liboctave and src directories.
Rik <rik@octave.org>
parents: 20945
diff changeset
63 # define OCTAVE_VERSION %OCTAVE_VERSION%
18152
91a3858ef8cf invoke versioned binaries from octave driver program (bug #40957)
John W. Eaton <jwe@octave.org>
parents: 18052
diff changeset
64 #endif
91a3858ef8cf invoke versioned binaries from octave driver program (bug #40957)
John W. Eaton <jwe@octave.org>
parents: 18052
diff changeset
65
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21440
diff changeset
66 #if ! defined (OCTAVE_ARCHLIBDIR)
21202
f7121e111991 maint: indent #ifdef blocks in liboctave and src directories.
Rik <rik@octave.org>
parents: 20945
diff changeset
67 # define OCTAVE_ARCHLIBDIR %OCTAVE_ARCHLIBDIR%
18163
65e4e0569ed4 install octave-gui binary in libexec directory
John W. Eaton <jwe@octave.org>
parents: 18152
diff changeset
68 #endif
65e4e0569ed4 install octave-gui binary in libexec directory
John W. Eaton <jwe@octave.org>
parents: 18152
diff changeset
69
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21440
diff changeset
70 #if ! defined (OCTAVE_BINDIR)
21202
f7121e111991 maint: indent #ifdef blocks in liboctave and src directories.
Rik <rik@octave.org>
parents: 20945
diff changeset
71 # define OCTAVE_BINDIR %OCTAVE_BINDIR%
18152
91a3858ef8cf invoke versioned binaries from octave driver program (bug #40957)
John W. Eaton <jwe@octave.org>
parents: 18052
diff changeset
72 #endif
91a3858ef8cf invoke versioned binaries from octave driver program (bug #40957)
John W. Eaton <jwe@octave.org>
parents: 18052
diff changeset
73
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21440
diff changeset
74 #if ! defined (OCTAVE_PREFIX)
21202
f7121e111991 maint: indent #ifdef blocks in liboctave and src directories.
Rik <rik@octave.org>
parents: 20945
diff changeset
75 # define OCTAVE_PREFIX %OCTAVE_PREFIX%
18152
91a3858ef8cf invoke versioned binaries from octave driver program (bug #40957)
John W. Eaton <jwe@octave.org>
parents: 18052
diff changeset
76 #endif
91a3858ef8cf invoke versioned binaries from octave driver program (bug #40957)
John W. Eaton <jwe@octave.org>
parents: 18052
diff changeset
77
23712
b95c430c0649 revamp insertion of config variables into binaries and eliminate some macros
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
78 #if ! defined (OCTAVE_EXEC_PREFIX)
b95c430c0649 revamp insertion of config variables into binaries and eliminate some macros
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
79 # define OCTAVE_EXEC_PREFIX %OCTAVE_EXEC_PREFIX%
b95c430c0649 revamp insertion of config variables into binaries and eliminate some macros
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
80 #endif
b95c430c0649 revamp insertion of config variables into binaries and eliminate some macros
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
81
19785
299fe39163a2 avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
82 #include "display-available.h"
29898
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
83 #include "options.h"
18360
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents: 18163
diff changeset
84 #include "shared-fcns.h"
17782
136a9e27256e automatically locate wrapper binary on Windows systems (bug #40381)
John W. Eaton <jwe@octave.org>
parents: 17780
diff changeset
85
21979
d04da18a407a use OCTAVE_USE_WINDOWS_API more consistently
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
86 #if defined (HAVE_OCTAVE_QT_GUI) && ! defined (OCTAVE_USE_WINDOWS_API)
29593
250cefb729d1 fix thinko in 3bfec185c9e2 (bug #60498)
John W. Eaton <jwe@octave.org>
parents: 29572
diff changeset
87 static bool fork_and_exec = true;
29503
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
88 #else
29593
250cefb729d1 fix thinko in 3bfec185c9e2 (bug #60498)
John W. Eaton <jwe@octave.org>
parents: 29572
diff changeset
89 static bool fork_and_exec = false;
29503
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
90 #endif
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
91
29503
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
92 // If we fork and exec, we'll need the following signal handling code to
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
93 // forward signals to the GUI process.
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
94
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
95 static pid_t gui_pid = 0;
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
96
17865
dde06c2ac6c6 improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents: 17814
diff changeset
97 static int caught_signal = -1;
dde06c2ac6c6 improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents: 17814
diff changeset
98
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
99 static void
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
100 gui_driver_sig_handler (int sig)
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
101 {
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
102 if (gui_pid > 0)
17865
dde06c2ac6c6 improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents: 17814
diff changeset
103 caught_signal = sig;
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
104 }
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
105
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21927
diff changeset
106 static void
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21927
diff changeset
107 gui_driver_set_signal_handler (const char *signame,
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21927
diff changeset
108 octave_sig_handler *handler)
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
109 {
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21927
diff changeset
110 octave_set_signal_handler_by_name (signame, handler, false);
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
111 }
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
112
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
113 static void
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
114 install_signal_handlers (void)
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
115 {
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24163
diff changeset
116 // FIXME: do we need to handle and forward all the signals that Octave
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24163
diff changeset
117 // handles, or is it sufficient to only forward things like SIGINT,
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24163
diff changeset
118 // SIGBREAK, SIGABRT, SIGQUIT, and possibly a few others?
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24163
diff changeset
119
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21927
diff changeset
120 gui_driver_set_signal_handler ("SIGINT", gui_driver_sig_handler);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21927
diff changeset
121 gui_driver_set_signal_handler ("SIGBREAK", gui_driver_sig_handler);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21927
diff changeset
122 gui_driver_set_signal_handler ("SIGABRT", gui_driver_sig_handler);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21927
diff changeset
123 gui_driver_set_signal_handler ("SIGALRM", gui_driver_sig_handler);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21927
diff changeset
124 gui_driver_set_signal_handler ("SIGBUS", gui_driver_sig_handler);
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
125
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
126 // SIGCHLD
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
127 // SIGCLD
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
128 // SIGCONT
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
129
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21927
diff changeset
130 gui_driver_set_signal_handler ("SIGEMT", gui_driver_sig_handler);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21927
diff changeset
131 gui_driver_set_signal_handler ("SIGFPE", gui_driver_sig_handler);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21927
diff changeset
132 gui_driver_set_signal_handler ("SIGHUP", gui_driver_sig_handler);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21927
diff changeset
133 gui_driver_set_signal_handler ("SIGILL", gui_driver_sig_handler);
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
134
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
135 // SIGINFO
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
136 // SIGINT
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
137
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21927
diff changeset
138 gui_driver_set_signal_handler ("SIGIOT", gui_driver_sig_handler);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21927
diff changeset
139 gui_driver_set_signal_handler ("SIGLOST", gui_driver_sig_handler);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21927
diff changeset
140 gui_driver_set_signal_handler ("SIGPIPE", gui_driver_sig_handler);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21927
diff changeset
141 gui_driver_set_signal_handler ("SIGPOLL", gui_driver_sig_handler);
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
142
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
143 // SIGPROF
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
144 // SIGPWR
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
145
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21927
diff changeset
146 gui_driver_set_signal_handler ("SIGQUIT", gui_driver_sig_handler);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21927
diff changeset
147 gui_driver_set_signal_handler ("SIGSEGV", gui_driver_sig_handler);
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
148
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
149 // SIGSTOP
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
150
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21927
diff changeset
151 gui_driver_set_signal_handler ("SIGSYS", gui_driver_sig_handler);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21927
diff changeset
152 gui_driver_set_signal_handler ("SIGTERM", gui_driver_sig_handler);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21927
diff changeset
153 gui_driver_set_signal_handler ("SIGTRAP", gui_driver_sig_handler);
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
154
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
155 // SIGTSTP
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
156 // SIGTTIN
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
157 // SIGTTOU
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
158 // SIGURG
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
159
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21927
diff changeset
160 gui_driver_set_signal_handler ("SIGUSR1", gui_driver_sig_handler);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21927
diff changeset
161 gui_driver_set_signal_handler ("SIGUSR2", gui_driver_sig_handler);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21927
diff changeset
162 gui_driver_set_signal_handler ("SIGVTALRM", gui_driver_sig_handler);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21927
diff changeset
163 gui_driver_set_signal_handler ("SIGIO", gui_driver_sig_handler);
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
164
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
165 // SIGWINCH
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
166
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21927
diff changeset
167 gui_driver_set_signal_handler ("SIGXCPU", gui_driver_sig_handler);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21927
diff changeset
168 gui_driver_set_signal_handler ("SIGXFSZ", gui_driver_sig_handler);
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
169 }
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
170
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
171 static std::string
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
172 get_octave_bindir (void)
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
173 {
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
174 // Accept value from the environment literally, but substitute
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
175 // OCTAVE_HOME in the configuration value OCTAVE_BINDIR in case Octave
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
176 // has been relocated to some installation directory other than the
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
177 // one originally configured.
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
178
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
179 std::string obd = octave_getenv ("OCTAVE_BINDIR");
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
180
27934
49a0d90cd2a3 maint: Use Octave coding conventions in src/ directory.
Rik <rik@octave.org>
parents: 27923
diff changeset
181 return obd.empty () ? prepend_octave_exec_home (std::string (OCTAVE_BINDIR))
49a0d90cd2a3 maint: Use Octave coding conventions in src/ directory.
Rik <rik@octave.org>
parents: 27923
diff changeset
182 : obd;
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
183 }
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
184
18163
65e4e0569ed4 install octave-gui binary in libexec directory
John W. Eaton <jwe@octave.org>
parents: 18152
diff changeset
185 static std::string
65e4e0569ed4 install octave-gui binary in libexec directory
John W. Eaton <jwe@octave.org>
parents: 18152
diff changeset
186 get_octave_archlibdir (void)
65e4e0569ed4 install octave-gui binary in libexec directory
John W. Eaton <jwe@octave.org>
parents: 18152
diff changeset
187 {
65e4e0569ed4 install octave-gui binary in libexec directory
John W. Eaton <jwe@octave.org>
parents: 18152
diff changeset
188 // Accept value from the environment literally, but substitute
65e4e0569ed4 install octave-gui binary in libexec directory
John W. Eaton <jwe@octave.org>
parents: 18152
diff changeset
189 // OCTAVE_HOME in the configuration value OCTAVE_ARCHLIBDIR in case
65e4e0569ed4 install octave-gui binary in libexec directory
John W. Eaton <jwe@octave.org>
parents: 18152
diff changeset
190 // Octave has been relocated to some installation directory other than
65e4e0569ed4 install octave-gui binary in libexec directory
John W. Eaton <jwe@octave.org>
parents: 18152
diff changeset
191 // the one originally configured.
65e4e0569ed4 install octave-gui binary in libexec directory
John W. Eaton <jwe@octave.org>
parents: 18152
diff changeset
192
65e4e0569ed4 install octave-gui binary in libexec directory
John W. Eaton <jwe@octave.org>
parents: 18152
diff changeset
193 std::string dir = octave_getenv ("OCTAVE_ARCHLIBDIR");
65e4e0569ed4 install octave-gui binary in libexec directory
John W. Eaton <jwe@octave.org>
parents: 18152
diff changeset
194
23712
b95c430c0649 revamp insertion of config variables into binaries and eliminate some macros
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
195 return dir.empty () ? prepend_octave_exec_home (std::string (OCTAVE_ARCHLIBDIR))
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19785
diff changeset
196 : dir;
18163
65e4e0569ed4 install octave-gui binary in libexec directory
John W. Eaton <jwe@octave.org>
parents: 18152
diff changeset
197 }
65e4e0569ed4 install octave-gui binary in libexec directory
John W. Eaton <jwe@octave.org>
parents: 18152
diff changeset
198
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
199 static int
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
200 octave_exec (const std::string& file, char **argv)
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
201 {
21949
baeffde5c87d fix build for Windows systems
John W. Eaton <jwe@octave.org>
parents: 21944
diff changeset
202 int status = octave_execv_wrapper (file.c_str (), argv);
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
203
21949
baeffde5c87d fix build for Windows systems
John W. Eaton <jwe@octave.org>
parents: 21944
diff changeset
204 std::cerr << argv[0] << ": failed to exec '" << file << "'" << std::endl;
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
205
21949
baeffde5c87d fix build for Windows systems
John W. Eaton <jwe@octave.org>
parents: 21944
diff changeset
206 return status;
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
207 }
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
208
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
209 static char *
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
210 strsave (const char *s)
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
211 {
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
212 if (! s)
23796
4f12819a634f Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23767
diff changeset
213 return nullptr;
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
214
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
215 int len = strlen (s);
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
216 char *tmp = new char [len+1];
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
217 tmp = strcpy (tmp, s);
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
218 return tmp;
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
219 }
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
220
29540
b6f80b1d448f Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29510
diff changeset
221 #if defined (OCTAVE_USE_WINDOWS_API) && defined (_UNICODE)
b6f80b1d448f Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29510
diff changeset
222 extern "C"
b6f80b1d448f Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29510
diff changeset
223 int
b6f80b1d448f Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29510
diff changeset
224 wmain (int argc, wchar_t **wargv)
b6f80b1d448f Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29510
diff changeset
225 {
b6f80b1d448f Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29510
diff changeset
226 static char **argv = new char * [argc + 1];
b6f80b1d448f Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29510
diff changeset
227 std::vector<std::string> argv_str;
b6f80b1d448f Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29510
diff changeset
228
b6f80b1d448f Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29510
diff changeset
229 // convert wide character strings to multibyte UTF-8 strings
b6f80b1d448f Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29510
diff changeset
230 std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> wchar_conv;
b6f80b1d448f Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29510
diff changeset
231 for (int i_arg = 0; i_arg < argc; i_arg++)
30192
8c8031be8072 Windows: Don't get pointers to C strings while vector is still unstable.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29911
diff changeset
232 argv_str.push_back (wchar_conv.to_bytes (wargv[i_arg]));
8c8031be8072 Windows: Don't get pointers to C strings while vector is still unstable.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29911
diff changeset
233
8c8031be8072 Windows: Don't get pointers to C strings while vector is still unstable.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29911
diff changeset
234 // Get pointers to C strings not before vector is stable.
8c8031be8072 Windows: Don't get pointers to C strings while vector is still unstable.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29911
diff changeset
235 for (int i_arg = 0; i_arg < argc; i_arg++)
8c8031be8072 Windows: Don't get pointers to C strings while vector is still unstable.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29911
diff changeset
236 argv[i_arg] = &argv_str[i_arg][0];
29540
b6f80b1d448f Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29510
diff changeset
237 argv[argc] = nullptr;
b6f80b1d448f Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29510
diff changeset
238
b6f80b1d448f Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29510
diff changeset
239 #else
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
240 int
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
241 main (int argc, char **argv)
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
242 {
29540
b6f80b1d448f Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29510
diff changeset
243 #endif
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
244 int retval = 0;
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
245
29189
0fc400f15e35 avoid gui when octave is launched in non-interactive mode (bug #59628)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27934
diff changeset
246 int idx_gui = -1;
29254
11343ca3c125 allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents: 29237
diff changeset
247 bool server = false;
24898
91331c76d9c1 invert the logic for whether to start the GUI in the octave wrapper
Mike Miller <mtmiller@octave.org>
parents: 24534
diff changeset
248 bool start_gui = false;
18014
6df05f2fd354 maint: Back out changeset 25b6fbe82827 and set default to GUI for 4.0 release.
Rik <rik@octave.org>
parents: 18008
diff changeset
249 bool gui_libs = true;
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
250
29189
0fc400f15e35 avoid gui when octave is launched in non-interactive mode (bug #59628)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27934
diff changeset
251 bool eval_code = false;
0fc400f15e35 avoid gui when octave is launched in non-interactive mode (bug #59628)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27934
diff changeset
252 bool persist_octave = false;
0fc400f15e35 avoid gui when octave is launched in non-interactive mode (bug #59628)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27934
diff changeset
253
23712
b95c430c0649 revamp insertion of config variables into binaries and eliminate some macros
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
254 set_octave_home ();
b95c430c0649 revamp insertion of config variables into binaries and eliminate some macros
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
255
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
256 std::string octave_bindir = get_octave_bindir ();
18163
65e4e0569ed4 install octave-gui binary in libexec directory
John W. Eaton <jwe@octave.org>
parents: 18152
diff changeset
257 std::string octave_archlibdir = get_octave_archlibdir ();
21284
1bbd799ac7c7 Invoke correct version of octave-cli from main driver program
Mike Miller <mtmiller@octave.org>
parents: 19861
diff changeset
258 std::string octave_cli
1bbd799ac7c7 Invoke correct version of octave-cli from main driver program
Mike Miller <mtmiller@octave.org>
parents: 19861
diff changeset
259 = octave_bindir + dir_sep_char + "octave-cli-" OCTAVE_VERSION;
1bbd799ac7c7 Invoke correct version of octave-cli from main driver program
Mike Miller <mtmiller@octave.org>
parents: 19861
diff changeset
260 std::string octave_gui = octave_archlibdir + dir_sep_char + "octave-gui";
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
261
21374
1487a68a496a untangle configuration of OpenGL, FLTK, and Qt (bug #47263)
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
262 #if defined (HAVE_OCTAVE_QT_GUI)
18164
eb51f47d9dee maint: Periodic merge of stable to gui-release.
John W. Eaton <jwe@octave.org>
parents: 18157 18163
diff changeset
263 // The Octave version number is already embedded in the
eb51f47d9dee maint: Periodic merge of stable to gui-release.
John W. Eaton <jwe@octave.org>
parents: 18157 18163
diff changeset
264 // octave_archlibdir directory name so we don't need to append it to
20713
2469d78a1d8b Consistently use 'filename' rather than 'file name' throughout code base.
Rik <rik@octave.org>
parents: 19861
diff changeset
265 // the octave-gui filename.
18164
eb51f47d9dee maint: Periodic merge of stable to gui-release.
John W. Eaton <jwe@octave.org>
parents: 18157 18163
diff changeset
266
21284
1bbd799ac7c7 Invoke correct version of octave-cli from main driver program
Mike Miller <mtmiller@octave.org>
parents: 19861
diff changeset
267 std::string file = octave_gui;
18014
6df05f2fd354 maint: Back out changeset 25b6fbe82827 and set default to GUI for 4.0 release.
Rik <rik@octave.org>
parents: 18008
diff changeset
268 #else
21284
1bbd799ac7c7 Invoke correct version of octave-cli from main driver program
Mike Miller <mtmiller@octave.org>
parents: 19861
diff changeset
269 std::string file = octave_cli;
18014
6df05f2fd354 maint: Back out changeset 25b6fbe82827 and set default to GUI for 4.0 release.
Rik <rik@octave.org>
parents: 18008
diff changeset
270 #endif
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
271
21440
062c65569ad7 avoid some address-sanitizer leak warnings (bug #47372)
John W. Eaton <jwe@octave.org>
parents: 21374
diff changeset
272 // Declaring new_argv static avoids leak warnings when using GCC's
062c65569ad7 avoid some address-sanitizer leak warnings (bug #47372)
John W. Eaton <jwe@octave.org>
parents: 21374
diff changeset
273 // --address-sanitizer option.
29191
ae5d758c10e1 Increase size of dynamic variable new_argv by 1 to avoid indexing out of array.
Rik <rik@octave.org>
parents: 29189
diff changeset
274 static char **new_argv = new char * [argc + 2];
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
275
29898
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
276 int next_optind = 1;
17959
1329866151be [Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17865
diff changeset
277 int k = 1;
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
278
17994
a99b7d656a6c start in CLI mode if display is not available (bug #40685)
John W. Eaton <jwe@octave.org>
parents: 17959
diff changeset
279 bool warn_display = true;
21783
58a4c5633efd Disable plotting graphics when --no-window-system used (bug #48017).
Rik <rik@octave.org>
parents: 21724
diff changeset
280 bool no_display = false;
17994
a99b7d656a6c start in CLI mode if display is not available (bug #40685)
John W. Eaton <jwe@octave.org>
parents: 17959
diff changeset
281
29910
0f41e117789f disable getopt error reporting in wrapper program (bug #60886)
John W. Eaton <jwe@octave.org>
parents: 29908
diff changeset
282 // Disable error reporting in getopt. We want to silently recognize
0f41e117789f disable getopt error reporting in wrapper program (bug #60886)
John W. Eaton <jwe@octave.org>
parents: 29908
diff changeset
283 // and process a few special arguments here and pass everything on to
0f41e117789f disable getopt error reporting in wrapper program (bug #60886)
John W. Eaton <jwe@octave.org>
parents: 29908
diff changeset
284 // the real Octave program where incorrect usage errors may be
0f41e117789f disable getopt error reporting in wrapper program (bug #60886)
John W. Eaton <jwe@octave.org>
parents: 29908
diff changeset
285 // reported.
0f41e117789f disable getopt error reporting in wrapper program (bug #60886)
John W. Eaton <jwe@octave.org>
parents: 29908
diff changeset
286
0f41e117789f disable getopt error reporting in wrapper program (bug #60886)
John W. Eaton <jwe@octave.org>
parents: 29908
diff changeset
287 octave_set_opterr_wrapper (0);
0f41e117789f disable getopt error reporting in wrapper program (bug #60886)
John W. Eaton <jwe@octave.org>
parents: 29908
diff changeset
288
29898
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
289 while (true)
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
290 {
29898
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
291 int long_idx;
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
292
29898
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
293 int optc = octave_getopt_long_wrapper (argc, argv, short_opts, long_opts,
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
294 &long_idx);
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
295 int old_optind = next_optind;
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
296 next_optind = octave_optind_wrapper ();
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
297
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
298 if (optc < 0)
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
299 break;
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
300
29898
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
301 switch (optc)
24898
91331c76d9c1 invert the logic for whether to start the GUI in the octave wrapper
Mike Miller <mtmiller@octave.org>
parents: 24534
diff changeset
302 {
29898
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
303 case NO_GUI_LIBS_OPTION:
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
304 // Run the version of Octave that is not linked with any GUI
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
305 // libraries. It may not be possible to do plotting or any ui*
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
306 // calls, but it will be a little faster to start and require less
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
307 // memory. Don't pass the --no-gui-libs option on as that option
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
308 // is not recognized by Octave.
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
309 gui_libs = false;
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
310 file = octave_cli;
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
311 break;
24898
91331c76d9c1 invert the logic for whether to start the GUI in the octave wrapper
Mike Miller <mtmiller@octave.org>
parents: 24534
diff changeset
312
29898
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
313 case NO_GUI_OPTION:
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
314 // If we see this option, then we can just exec octave; we don't
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
315 // have to create a child process and wait for it to exit. But do
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
316 // exec "octave-gui", not "octave-cli", because even if the
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
317 // --no-gui option is given, we may be asked to do some plotting or
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
318 // ui* calls.
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
319 start_gui = false;
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
320 new_argv[k++] = argv[old_optind];
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
321 break;
29191
ae5d758c10e1 Increase size of dynamic variable new_argv by 1 to avoid indexing out of array.
Rik <rik@octave.org>
parents: 29189
diff changeset
322
29898
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
323 case GUI_OPTION:
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
324 // If we see this option, then we fork and exec octave with the
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
325 // --gui option, while continuing to handle signals in the
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
326 // terminal.
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
327 // Do not copy the arg now, since we still not know if the gui
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
328 // should really be launched. Just store the index.
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
329 start_gui = true;
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
330 idx_gui = old_optind;
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
331 break;
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
332
29890
bc19d9360bac main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29655
diff changeset
333 case EXPERIMENTAL_TERMINAL_WIDGET_OPTION:
bc19d9360bac main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29655
diff changeset
334 // If we see this option, then we don't fork and exec.
bc19d9360bac main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29655
diff changeset
335 fork_and_exec = false;
bc19d9360bac main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29655
diff changeset
336 new_argv[k++] = argv[old_optind];
bc19d9360bac main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29655
diff changeset
337 break;
29898
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
338
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
339 case PERSIST_OPTION:
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
340 // FIXME: How can we reliably detect if this option appears after
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
341 // a FILE argument. In this case octave ignores the option,
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
342 // but the GUI might still be launched if --gui is also
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
343 // given.
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
344 persist_octave = true;
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
345 new_argv[k++] = argv[old_optind];
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
346 break;
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
347
29890
bc19d9360bac main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29655
diff changeset
348 case SERVER_OPTION:
bc19d9360bac main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29655
diff changeset
349 server = true;
bc19d9360bac main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29655
diff changeset
350 new_argv[k++] = argv[old_optind];
bc19d9360bac main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29655
diff changeset
351 break;
bc19d9360bac main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29655
diff changeset
352
29898
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
353 case EVAL_OPTION:
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
354 eval_code = true;
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
355 for (int i = old_optind; i < next_optind; i++)
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
356 new_argv[k++] = argv[i];
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
357 break;
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
358
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
359 case 'q':
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
360 // options "--silent" or "--quiet"
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
361 warn_display = false;
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
362 new_argv[k++] = argv[old_optind];
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
363 break;
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
364
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
365 case 'W':
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
366 // option "--no-window-system"
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
367 no_display = true;
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
368 new_argv[k++] = argv[old_optind];
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
369 break;
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
370
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
371 default:
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
372 for (int i = old_optind; i < next_optind; i++)
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
373 new_argv[k++] = argv[i];
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
374 break;
21783
58a4c5633efd Disable plotting graphics when --no-window-system used (bug #48017).
Rik <rik@octave.org>
parents: 21724
diff changeset
375 }
29898
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
376 }
23767
2387ce427601 improve handling of single-letter command line options (bug #51461)
Mike Miller <mtmiller@octave.org>
parents: 23712
diff changeset
377
29908
3583b11e151b main.cc: Remove invalid case (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29898
diff changeset
378 // Treat trailing arguments as commands to be executed
29898
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
379 if (next_optind < argc)
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
380 {
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
381 eval_code = true;
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
382 for (int i = next_optind; i < argc; i++)
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
383 new_argv[k++] = argv[i];
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
384 }
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
385
29189
0fc400f15e35 avoid gui when octave is launched in non-interactive mode (bug #59628)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27934
diff changeset
386 if (start_gui && eval_code && ! persist_octave)
0fc400f15e35 avoid gui when octave is launched in non-interactive mode (bug #59628)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27934
diff changeset
387 start_gui = false;
25068
53440f9bffba disallow --gui option without GUI features (bug #53529)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
388
29189
0fc400f15e35 avoid gui when octave is launched in non-interactive mode (bug #59628)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27934
diff changeset
389 // At this point, we definitely know whether the gui has to
0fc400f15e35 avoid gui when octave is launched in non-interactive mode (bug #59628)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27934
diff changeset
390 // be launched or not.
0fc400f15e35 avoid gui when octave is launched in non-interactive mode (bug #59628)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27934
diff changeset
391 // gui_libs and start_gui are just about options, not
29191
ae5d758c10e1 Increase size of dynamic variable new_argv by 1 to avoid indexing out of array.
Rik <rik@octave.org>
parents: 29189
diff changeset
392 // the environment. Exit if they don't make sense.
25068
53440f9bffba disallow --gui option without GUI features (bug #53529)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
393 if (start_gui)
53440f9bffba disallow --gui option without GUI features (bug #53529)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
394 {
29189
0fc400f15e35 avoid gui when octave is launched in non-interactive mode (bug #59628)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27934
diff changeset
395 // GUI should be started
25068
53440f9bffba disallow --gui option without GUI features (bug #53529)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
396 if (! gui_libs)
53440f9bffba disallow --gui option without GUI features (bug #53529)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
397 {
53440f9bffba disallow --gui option without GUI features (bug #53529)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
398 std::cerr << "octave: conflicting options: --no-gui-libs and --gui"
53440f9bffba disallow --gui option without GUI features (bug #53529)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
399 << std::endl;
53440f9bffba disallow --gui option without GUI features (bug #53529)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
400 return 1;
53440f9bffba disallow --gui option without GUI features (bug #53529)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
401 }
53440f9bffba disallow --gui option without GUI features (bug #53529)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
402
29254
11343ca3c125 allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents: 29237
diff changeset
403 if (server)
11343ca3c125 allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents: 29237
diff changeset
404 {
11343ca3c125 allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents: 29237
diff changeset
405 std::cerr << "octave: conflicting options: --server and --gui"
11343ca3c125 allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents: 29237
diff changeset
406 << std::endl;
11343ca3c125 allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents: 29237
diff changeset
407 return 1;
11343ca3c125 allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents: 29237
diff changeset
408 }
11343ca3c125 allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents: 29237
diff changeset
409
25068
53440f9bffba disallow --gui option without GUI features (bug #53529)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
410 #if ! defined (HAVE_OCTAVE_QT_GUI)
53440f9bffba disallow --gui option without GUI features (bug #53529)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
411 std::cerr << "octave: GUI features missing or disabled in this build"
53440f9bffba disallow --gui option without GUI features (bug #53529)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
412 << std::endl;
53440f9bffba disallow --gui option without GUI features (bug #53529)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
413 return 1;
53440f9bffba disallow --gui option without GUI features (bug #53529)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
414 #endif
29189
0fc400f15e35 avoid gui when octave is launched in non-interactive mode (bug #59628)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27934
diff changeset
415
0fc400f15e35 avoid gui when octave is launched in non-interactive mode (bug #59628)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27934
diff changeset
416 // Finally, add --gui to the command line options. We can not
0fc400f15e35 avoid gui when octave is launched in non-interactive mode (bug #59628)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27934
diff changeset
417 // just append it since options after a given file are ignored.
0fc400f15e35 avoid gui when octave is launched in non-interactive mode (bug #59628)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27934
diff changeset
418 for (int j = k; j > 1; j--)
0fc400f15e35 avoid gui when octave is launched in non-interactive mode (bug #59628)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27934
diff changeset
419 new_argv[j] = new_argv[j-1];
0fc400f15e35 avoid gui when octave is launched in non-interactive mode (bug #59628)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27934
diff changeset
420
0fc400f15e35 avoid gui when octave is launched in non-interactive mode (bug #59628)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27934
diff changeset
421 new_argv[1] = argv[idx_gui];
0fc400f15e35 avoid gui when octave is launched in non-interactive mode (bug #59628)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27934
diff changeset
422 k++;
25068
53440f9bffba disallow --gui option without GUI features (bug #53529)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
423 }
53440f9bffba disallow --gui option without GUI features (bug #53529)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
424
23796
4f12819a634f Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23767
diff changeset
425 new_argv[k] = nullptr;
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
426
21783
58a4c5633efd Disable plotting graphics when --no-window-system used (bug #48017).
Rik <rik@octave.org>
parents: 21724
diff changeset
427 if (no_display)
58a4c5633efd Disable plotting graphics when --no-window-system used (bug #48017).
Rik <rik@octave.org>
parents: 21724
diff changeset
428 {
58a4c5633efd Disable plotting graphics when --no-window-system used (bug #48017).
Rik <rik@octave.org>
parents: 21724
diff changeset
429 start_gui = false;
58a4c5633efd Disable plotting graphics when --no-window-system used (bug #48017).
Rik <rik@octave.org>
parents: 21724
diff changeset
430 gui_libs = false;
58a4c5633efd Disable plotting graphics when --no-window-system used (bug #48017).
Rik <rik@octave.org>
parents: 21724
diff changeset
431
58a4c5633efd Disable plotting graphics when --no-window-system used (bug #48017).
Rik <rik@octave.org>
parents: 21724
diff changeset
432 file = octave_cli;
58a4c5633efd Disable plotting graphics when --no-window-system used (bug #48017).
Rik <rik@octave.org>
parents: 21724
diff changeset
433 }
58a4c5633efd Disable plotting graphics when --no-window-system used (bug #48017).
Rik <rik@octave.org>
parents: 21724
diff changeset
434 else if (gui_libs || start_gui)
17994
a99b7d656a6c start in CLI mode if display is not available (bug #40685)
John W. Eaton <jwe@octave.org>
parents: 17959
diff changeset
435 {
19785
299fe39163a2 avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
436 int dpy_avail;
17994
a99b7d656a6c start in CLI mode if display is not available (bug #40685)
John W. Eaton <jwe@octave.org>
parents: 17959
diff changeset
437
19785
299fe39163a2 avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
438 const char *display_check_err_msg = display_available (&dpy_avail);
299fe39163a2 avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
439
299fe39163a2 avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
440 if (! dpy_avail)
17994
a99b7d656a6c start in CLI mode if display is not available (bug #40685)
John W. Eaton <jwe@octave.org>
parents: 17959
diff changeset
441 {
a99b7d656a6c start in CLI mode if display is not available (bug #40685)
John W. Eaton <jwe@octave.org>
parents: 17959
diff changeset
442 start_gui = false;
a99b7d656a6c start in CLI mode if display is not available (bug #40685)
John W. Eaton <jwe@octave.org>
parents: 17959
diff changeset
443 gui_libs = false;
a99b7d656a6c start in CLI mode if display is not available (bug #40685)
John W. Eaton <jwe@octave.org>
parents: 17959
diff changeset
444
21284
1bbd799ac7c7 Invoke correct version of octave-cli from main driver program
Mike Miller <mtmiller@octave.org>
parents: 19861
diff changeset
445 file = octave_cli;
17994
a99b7d656a6c start in CLI mode if display is not available (bug #40685)
John W. Eaton <jwe@octave.org>
parents: 17959
diff changeset
446
a99b7d656a6c start in CLI mode if display is not available (bug #40685)
John W. Eaton <jwe@octave.org>
parents: 17959
diff changeset
447 if (warn_display)
a99b7d656a6c start in CLI mode if display is not available (bug #40685)
John W. Eaton <jwe@octave.org>
parents: 17959
diff changeset
448 {
19785
299fe39163a2 avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
449 if (! display_check_err_msg)
299fe39163a2 avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
450 display_check_err_msg = "graphical display unavailable";
299fe39163a2 avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
451
17994
a99b7d656a6c start in CLI mode if display is not available (bug #40685)
John W. Eaton <jwe@octave.org>
parents: 17959
diff changeset
452 std::cerr << "octave: " << display_check_err_msg << std::endl;
18052
0c4a2e95c768 Correct typo in error message when no DISPLAY var set.
Rik <rik@octave.org>
parents: 18012
diff changeset
453 std::cerr << "octave: disabling GUI features" << std::endl;
17994
a99b7d656a6c start in CLI mode if display is not available (bug #40685)
John W. Eaton <jwe@octave.org>
parents: 17959
diff changeset
454 }
a99b7d656a6c start in CLI mode if display is not available (bug #40685)
John W. Eaton <jwe@octave.org>
parents: 17959
diff changeset
455 }
a99b7d656a6c start in CLI mode if display is not available (bug #40685)
John W. Eaton <jwe@octave.org>
parents: 17959
diff changeset
456 }
a99b7d656a6c start in CLI mode if display is not available (bug #40685)
John W. Eaton <jwe@octave.org>
parents: 17959
diff changeset
457
21979
d04da18a407a use OCTAVE_USE_WINDOWS_API more consistently
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
458 #if defined (OCTAVE_USE_WINDOWS_API)
18152
91a3858ef8cf invoke versioned binaries from octave driver program (bug #40957)
John W. Eaton <jwe@octave.org>
parents: 18052
diff changeset
459 file += ".exe";
91a3858ef8cf invoke versioned binaries from octave driver program (bug #40957)
John W. Eaton <jwe@octave.org>
parents: 18052
diff changeset
460 #endif
91a3858ef8cf invoke versioned binaries from octave driver program (bug #40957)
John W. Eaton <jwe@octave.org>
parents: 18052
diff changeset
461
91a3858ef8cf invoke versioned binaries from octave driver program (bug #40957)
John W. Eaton <jwe@octave.org>
parents: 18052
diff changeset
462 new_argv[0] = strsave (file.c_str ());
91a3858ef8cf invoke versioned binaries from octave driver program (bug #40957)
John W. Eaton <jwe@octave.org>
parents: 18052
diff changeset
463
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24163
diff changeset
464 // The Octave interpreter may be multithreaded. If so, we attempt to
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24163
diff changeset
465 // ensure that signals are delivered to the main interpreter thread
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24163
diff changeset
466 // and no others by blocking signals before we exec the Octave
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24163
diff changeset
467 // interpreter executable. When that process starts, it will unblock
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24163
diff changeset
468 // signals in the main interpreter thread. When running the GUI as a
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24163
diff changeset
469 // subprocess, we also unblock signals that the parent process handles
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24163
diff changeset
470 // so we can forward them to the child.
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24163
diff changeset
471
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24163
diff changeset
472 octave_block_async_signals ();
26826
20881d195d20 fix handling of SIGTSTP (bug #51903)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
473 octave_block_signal_by_name ("SIGTSTP");
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24163
diff changeset
474
29503
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
475 if (fork_and_exec && gui_libs && start_gui)
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
476 {
23194
c897282f1ec8 always fork and exec when starting the gui (bug #49609)
John W. Eaton <jwe@octave.org>
parents: 23083
diff changeset
477 // Fork and exec when starting the GUI so that we will call
c897282f1ec8 always fork and exec when starting the gui (bug #49609)
John W. Eaton <jwe@octave.org>
parents: 23083
diff changeset
478 // setsid to give up the controlling terminal (if any) and so that
c897282f1ec8 always fork and exec when starting the gui (bug #49609)
John W. Eaton <jwe@octave.org>
parents: 23083
diff changeset
479 // the GUI process will be in a separate process group.
c897282f1ec8 always fork and exec when starting the gui (bug #49609)
John W. Eaton <jwe@octave.org>
parents: 23083
diff changeset
480 //
c897282f1ec8 always fork and exec when starting the gui (bug #49609)
John W. Eaton <jwe@octave.org>
parents: 23083
diff changeset
481 // The GUI process must be in a separate process group so that we
23196
b93e1d29790e * main.in.cc (main): Improve comment.
John W. Eaton <jwe@octave.org>
parents: 23194
diff changeset
482 // can send an interrupt signal to all child processes when
b93e1d29790e * main.in.cc (main): Improve comment.
John W. Eaton <jwe@octave.org>
parents: 23194
diff changeset
483 // interrupting the interpreter. See also bug #49609 and the
b93e1d29790e * main.in.cc (main): Improve comment.
John W. Eaton <jwe@octave.org>
parents: 23194
diff changeset
484 // function pthread_thread_manager::interrupt in the file
b93e1d29790e * main.in.cc (main): Improve comment.
John W. Eaton <jwe@octave.org>
parents: 23194
diff changeset
485 // libgui/src/thread-manager.cc.
23194
c897282f1ec8 always fork and exec when starting the gui (bug #49609)
John W. Eaton <jwe@octave.org>
parents: 23083
diff changeset
486
21927
6f62bd248919 use wrapper functions for mkoctfile and main
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
487 gui_pid = octave_fork_wrapper ();
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
488
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
489 if (gui_pid < 0)
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
490 {
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
491 std::cerr << "octave: fork failed!" << std::endl;
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
492
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
493 retval = 1;
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
494 }
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
495 else if (gui_pid == 0)
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
496 {
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
497 // Child.
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
498
21927
6f62bd248919 use wrapper functions for mkoctfile and main
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
499 if (octave_setsid_wrapper () < 0)
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
500 {
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
501 std::cerr << "octave: error calling setsid!" << std::endl;
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
502
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
503 retval = 1;
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
504 }
18722
f8203daed9d4 Abort Octave GUI if setsid() fails after fork().
Rik <rik@octave.org>
parents: 18361
diff changeset
505 else
f8203daed9d4 Abort Octave GUI if setsid() fails after fork().
Rik <rik@octave.org>
parents: 18361
diff changeset
506 retval = octave_exec (file, new_argv);
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
507 }
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
508 else
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
509 {
18007
25b6fbe82827 Make the CLI the default for the 3.8 release.
Rik <rik@octave.org>
parents: 18006
diff changeset
510 // Parent. Forward signals to child while waiting for it to exit.
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
511
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24163
diff changeset
512 install_signal_handlers ();
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24163
diff changeset
513
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24163
diff changeset
514 octave_unblock_async_signals ();
26826
20881d195d20 fix handling of SIGTSTP (bug #51903)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
515 octave_unblock_signal_by_name ("SIGTSTP");
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24163
diff changeset
516
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
517 int status;
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
518
17865
dde06c2ac6c6 improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents: 17814
diff changeset
519 while (true)
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
520 {
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21783
diff changeset
521 octave_waitpid_wrapper (gui_pid, &status, 0);
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
522
17865
dde06c2ac6c6 improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents: 17814
diff changeset
523 if (caught_signal > 0)
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
524 {
17865
dde06c2ac6c6 improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents: 17814
diff changeset
525 int sig = caught_signal;
dde06c2ac6c6 improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents: 17814
diff changeset
526
dde06c2ac6c6 improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents: 17814
diff changeset
527 caught_signal = -1;
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
528
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21927
diff changeset
529 octave_kill_wrapper (gui_pid, sig);
17865
dde06c2ac6c6 improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents: 17814
diff changeset
530 }
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21783
diff changeset
531 else if (octave_wifexited_wrapper (status))
17865
dde06c2ac6c6 improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents: 17814
diff changeset
532 {
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21783
diff changeset
533 retval = octave_wexitstatus_wrapper (status);
17865
dde06c2ac6c6 improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents: 17814
diff changeset
534 break;
dde06c2ac6c6 improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents: 17814
diff changeset
535 }
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21783
diff changeset
536 else if (octave_wifsignaled_wrapper (status))
17865
dde06c2ac6c6 improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents: 17814
diff changeset
537 {
dde06c2ac6c6 improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents: 17814
diff changeset
538 std::cerr << "octave exited with signal "
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21783
diff changeset
539 << octave_wtermsig_wrapper (status) << std::endl;
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
540 break;
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
541 }
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
542 }
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
543 }
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
544 }
17801
0b81d65d3c49 only fork and exec when starting gui
John W. Eaton <jwe@octave.org>
parents: 17789
diff changeset
545 else
21949
baeffde5c87d fix build for Windows systems
John W. Eaton <jwe@octave.org>
parents: 21944
diff changeset
546 {
baeffde5c87d fix build for Windows systems
John W. Eaton <jwe@octave.org>
parents: 21944
diff changeset
547 retval = octave_exec (file, new_argv);
baeffde5c87d fix build for Windows systems
John W. Eaton <jwe@octave.org>
parents: 21944
diff changeset
548
baeffde5c87d fix build for Windows systems
John W. Eaton <jwe@octave.org>
parents: 21944
diff changeset
549 if (retval < 0)
baeffde5c87d fix build for Windows systems
John W. Eaton <jwe@octave.org>
parents: 21944
diff changeset
550 std::cerr << argv[0] << ": " << std::strerror (errno) << std::endl;
baeffde5c87d fix build for Windows systems
John W. Eaton <jwe@octave.org>
parents: 21944
diff changeset
551 }
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
552
17813
0a887758d1cc fix compilation of main.cc on Windows
John W. Eaton <jwe@octave.org>
parents: 17805
diff changeset
553
17778
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
554 return retval;
b5d58667d32d new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff changeset
555 }