Mercurial > octave
annotate src/main.in.cc @ 33554:6f33e7ee3c3d default tip
add find widget to experimental terminal widget
* command-widget.cc (command_widget): initialize find widget without
close button, connect find widget signals to the new slots, add find
widget into layout;
(notice_settings): call find widget method for updating settings;
(console::find_incremental): new slot for incremental search;
(console::find): new slot for forward and backward search
* command-widget.h: include find-widget.h, new private slots
console::find and console::find_incremental,
new class variable containing find_widget some find history
* find-widget.cc (find_widget): add a clear button to the line edit
author | Torsten Lilge <ttl-octave@mailbox.org> |
---|---|
date | Thu, 09 May 2024 21:05:52 +0200 |
parents | 25e8f63da459 |
children |
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 // |
32632
2e484f9f1f18
maint: update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
32591
diff
changeset
|
5 // Copyright (C) 2012-2024 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 |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
114 install_signal_handlers () |
17778
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 |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
172 get_octave_bindir () |
17778
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 |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
186 get_octave_archlibdir () |
18163
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 |
30257
e1b0ed07895b
Don't use P_OVERLAY to spawn main process from wrapper executable on Windows (bug #61396).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30192
diff
changeset
|
204 #if defined (OCTAVE_USE_WINDOWS_API) |
e1b0ed07895b
Don't use P_OVERLAY to spawn main process from wrapper executable on Windows (bug #61396).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30192
diff
changeset
|
205 // The above wrapper uses spawn(P_WAIT,...) instead of exec on Windows. |
e1b0ed07895b
Don't use P_OVERLAY to spawn main process from wrapper executable on Windows (bug #61396).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30192
diff
changeset
|
206 if (status == -1) |
e1b0ed07895b
Don't use P_OVERLAY to spawn main process from wrapper executable on Windows (bug #61396).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30192
diff
changeset
|
207 #endif |
21949
baeffde5c87d
fix build for Windows systems
John W. Eaton <jwe@octave.org>
parents:
21944
diff
changeset
|
208 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
|
209 |
21949
baeffde5c87d
fix build for Windows systems
John W. Eaton <jwe@octave.org>
parents:
21944
diff
changeset
|
210 return status; |
17778
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 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
213 static char * |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
214 strsave (const char *s) |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
215 { |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
216 if (! s) |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23767
diff
changeset
|
217 return nullptr; |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
218 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
219 int len = strlen (s); |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
220 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
|
221 tmp = strcpy (tmp, s); |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
222 return tmp; |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
223 } |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
224 |
29540
b6f80b1d448f
Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29510
diff
changeset
|
225 #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
|
226 extern "C" |
b6f80b1d448f
Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29510
diff
changeset
|
227 int |
b6f80b1d448f
Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29510
diff
changeset
|
228 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
|
229 { |
b6f80b1d448f
Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29510
diff
changeset
|
230 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
|
231 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
|
232 |
b6f80b1d448f
Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29510
diff
changeset
|
233 // 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
|
234 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
|
235 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
|
236 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
|
237 |
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
|
238 // 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
|
239 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
|
240 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
|
241 argv[argc] = nullptr; |
b6f80b1d448f
Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29510
diff
changeset
|
242 |
b6f80b1d448f
Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29510
diff
changeset
|
243 #else |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
244 int |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
245 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
|
246 { |
29540
b6f80b1d448f
Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29510
diff
changeset
|
247 #endif |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
248 int retval = 0; |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
249 |
29189
0fc400f15e35
avoid gui when octave is launched in non-interactive mode (bug #59628)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27934
diff
changeset
|
250 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
|
251 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
|
252 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
|
253 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
|
254 |
29189
0fc400f15e35
avoid gui when octave is launched in non-interactive mode (bug #59628)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27934
diff
changeset
|
255 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
|
256 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
|
257 |
23712
b95c430c0649
revamp insertion of config variables into binaries and eliminate some macros
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
258 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
|
259 |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
260 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
|
261 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
|
262 std::string octave_cli |
1bbd799ac7c7
Invoke correct version of octave-cli from main driver program
Mike Miller <mtmiller@octave.org>
parents:
19861
diff
changeset
|
263 = 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
|
264 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
|
265 |
21374
1487a68a496a
untangle configuration of OpenGL, FLTK, and Qt (bug #47263)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
266 #if defined (HAVE_OCTAVE_QT_GUI) |
18164
eb51f47d9dee
maint: Periodic merge of stable to gui-release.
John W. Eaton <jwe@octave.org>
diff
changeset
|
267 // The Octave version number is already embedded in the |
eb51f47d9dee
maint: Periodic merge of stable to gui-release.
John W. Eaton <jwe@octave.org>
diff
changeset
|
268 // 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
|
269 // the octave-gui filename. |
18164
eb51f47d9dee
maint: Periodic merge of stable to gui-release.
John W. Eaton <jwe@octave.org>
diff
changeset
|
270 |
21284
1bbd799ac7c7
Invoke correct version of octave-cli from main driver program
Mike Miller <mtmiller@octave.org>
parents:
19861
diff
changeset
|
271 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
|
272 #else |
21284
1bbd799ac7c7
Invoke correct version of octave-cli from main driver program
Mike Miller <mtmiller@octave.org>
parents:
19861
diff
changeset
|
273 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
|
274 #endif |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
275 |
21440
062c65569ad7
avoid some address-sanitizer leak warnings (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
21374
diff
changeset
|
276 // 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
|
277 // --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
|
278 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
|
279 |
29898
dffd1c943f1a
main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29654
diff
changeset
|
280 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
|
281 int k = 1; |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
282 |
17994
a99b7d656a6c
start in CLI mode if display is not available (bug #40685)
John W. Eaton <jwe@octave.org>
parents:
17959
diff
changeset
|
283 bool warn_display = true; |
21783
58a4c5633efd
Disable plotting graphics when --no-window-system used (bug #48017).
Rik <rik@octave.org>
parents:
21724
diff
changeset
|
284 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
|
285 |
29910
0f41e117789f
disable getopt error reporting in wrapper program (bug #60886)
John W. Eaton <jwe@octave.org>
parents:
29908
diff
changeset
|
286 // 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
|
287 // 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
|
288 // 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
|
289 // reported. |
0f41e117789f
disable getopt error reporting in wrapper program (bug #60886)
John W. Eaton <jwe@octave.org>
parents:
29908
diff
changeset
|
290 |
0f41e117789f
disable getopt error reporting in wrapper program (bug #60886)
John W. Eaton <jwe@octave.org>
parents:
29908
diff
changeset
|
291 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
|
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 while (true) |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
294 { |
29898
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 long_idx; |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
296 |
29898
dffd1c943f1a
main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29654
diff
changeset
|
297 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
|
298 &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
|
299 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
|
300 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
|
301 |
dffd1c943f1a
main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29654
diff
changeset
|
302 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
|
303 break; |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
304 |
29898
dffd1c943f1a
main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29654
diff
changeset
|
305 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
|
306 { |
32591
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
307 case NO_GUI_LIBS_OPTION: |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
308 // Run the version of Octave that is not linked with any GUI |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
309 // libraries. It may not be possible to do plotting or any ui* |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
310 // calls, but it will be a little faster to start and require less |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
311 // memory. Don't pass the --no-gui-libs option on as that option |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
312 // is not recognized by Octave. |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
313 gui_libs = false; |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
314 file = octave_cli; |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
315 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
|
316 |
32669
b18af44b044b
Add new short form aliases of runtime long form options to octave.
Rik <rik@octave.org>
parents:
32632
diff
changeset
|
317 case 'G': |
b18af44b044b
Add new short form aliases of runtime long form options to octave.
Rik <rik@octave.org>
parents:
32632
diff
changeset
|
318 // option "--no-gui" |
32591
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
319 // If we see this option, then we can just exec octave; we don't |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
320 // have to create a child process and wait for it to exit. But do |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
321 // exec "octave-gui", not "octave-cli", because even if the |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
322 // --no-gui option is given, we may be asked to do some plotting or |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
323 // ui* calls. |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
324 start_gui = false; |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
325 new_argv[k++] = argv[old_optind]; |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
326 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
|
327 |
32669
b18af44b044b
Add new short form aliases of runtime long form options to octave.
Rik <rik@octave.org>
parents:
32632
diff
changeset
|
328 case 'g': |
32670
d469da7cb42f
Add comment accidentally dropped from cset b18af44b044b.
Rik <rik@octave.org>
parents:
32669
diff
changeset
|
329 // option "--gui" |
32591
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
330 // If we see this option, then we fork and exec octave with the |
32670
d469da7cb42f
Add comment accidentally dropped from cset b18af44b044b.
Rik <rik@octave.org>
parents:
32669
diff
changeset
|
331 // --gui option, while continuing to handle signals in the terminal. |
32591
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
332 // Do not copy the arg now, since we still not know if the gui |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
333 // should really be launched. Just store the index. |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
334 start_gui = true; |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
335 idx_gui = old_optind; |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
336 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
|
337 |
32591
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
338 case EXPERIMENTAL_TERMINAL_WIDGET_OPTION: |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
339 // If we see this option, then we don't fork and exec. |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
340 fork_and_exec = false; |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
341 new_argv[k++] = argv[old_optind]; |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
342 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
|
343 |
32591
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
344 case PERSIST_OPTION: |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
345 // FIXME: How can we reliably detect if this option appears after |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
346 // a FILE argument. In this case octave ignores the option, |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
347 // but the GUI might still be launched if --gui is also |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
348 // given. |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
349 persist_octave = true; |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
350 new_argv[k++] = argv[old_optind]; |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
351 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
|
352 |
32591
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
353 case SERVER_OPTION: |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
354 server = true; |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
355 new_argv[k++] = argv[old_optind]; |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
356 break; |
29890
bc19d9360bac
main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29655
diff
changeset
|
357 |
32669
b18af44b044b
Add new short form aliases of runtime long form options to octave.
Rik <rik@octave.org>
parents:
32632
diff
changeset
|
358 case 'e': |
b18af44b044b
Add new short form aliases of runtime long form options to octave.
Rik <rik@octave.org>
parents:
32632
diff
changeset
|
359 // option "--eval" |
32591
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
360 eval_code = true; |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
361 for (int i = old_optind; i < next_optind; i++) |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
362 new_argv[k++] = argv[i]; |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
363 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
|
364 |
32591
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
365 case 'q': |
32680
25e8f63da459
Prefer --quiet to --silent in Octave.
Rik <rik@octave.org>
parents:
32670
diff
changeset
|
366 // options "--quiet" or "--silent" |
32591
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
367 warn_display = false; |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
368 new_argv[k++] = argv[old_optind]; |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
369 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
|
370 |
32591
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
371 case 'W': |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
372 // option "--no-window-system" |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
373 no_display = true; |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
374 new_argv[k++] = argv[old_optind]; |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
375 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
|
376 |
32591
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
377 default: |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
378 for (int i = old_optind; i < next_optind; i++) |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
379 new_argv[k++] = argv[i]; |
a9dbbe06ca59
maint: C++ style check for src/ before 9.1 release.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
380 break; |
21783
58a4c5633efd
Disable plotting graphics when --no-window-system used (bug #48017).
Rik <rik@octave.org>
parents:
21724
diff
changeset
|
381 } |
29898
dffd1c943f1a
main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29654
diff
changeset
|
382 } |
23767
2387ce427601
improve handling of single-letter command line options (bug #51461)
Mike Miller <mtmiller@octave.org>
parents:
23712
diff
changeset
|
383 |
29908
3583b11e151b
main.cc: Remove invalid case (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29898
diff
changeset
|
384 // 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
|
385 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
|
386 { |
dffd1c943f1a
main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29654
diff
changeset
|
387 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
|
388 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
|
389 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
|
390 } |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
391 |
29189
0fc400f15e35
avoid gui when octave is launched in non-interactive mode (bug #59628)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27934
diff
changeset
|
392 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
|
393 start_gui = false; |
25068
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 // 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
|
396 // 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
|
397 // 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
|
398 // 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
|
399 if (start_gui) |
53440f9bffba
disallow --gui option without GUI features (bug #53529)
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
400 { |
29189
0fc400f15e35
avoid gui when octave is launched in non-interactive mode (bug #59628)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27934
diff
changeset
|
401 // GUI should be started |
25068
53440f9bffba
disallow --gui option without GUI features (bug #53529)
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
402 if (! gui_libs) |
53440f9bffba
disallow --gui option without GUI features (bug #53529)
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
403 { |
53440f9bffba
disallow --gui option without GUI features (bug #53529)
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
404 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
|
405 << std::endl; |
53440f9bffba
disallow --gui option without GUI features (bug #53529)
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
406 return 1; |
53440f9bffba
disallow --gui option without GUI features (bug #53529)
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
407 } |
53440f9bffba
disallow --gui option without GUI features (bug #53529)
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
408 |
29254
11343ca3c125
allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents:
29237
diff
changeset
|
409 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
|
410 { |
11343ca3c125
allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents:
29237
diff
changeset
|
411 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
|
412 << 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
|
413 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
|
414 } |
11343ca3c125
allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents:
29237
diff
changeset
|
415 |
25068
53440f9bffba
disallow --gui option without GUI features (bug #53529)
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
416 #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
|
417 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
|
418 << std::endl; |
53440f9bffba
disallow --gui option without GUI features (bug #53529)
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
419 return 1; |
53440f9bffba
disallow --gui option without GUI features (bug #53529)
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
420 #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
|
421 |
0fc400f15e35
avoid gui when octave is launched in non-interactive mode (bug #59628)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27934
diff
changeset
|
422 // 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
|
423 // 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
|
424 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
|
425 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
|
426 |
0fc400f15e35
avoid gui when octave is launched in non-interactive mode (bug #59628)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27934
diff
changeset
|
427 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
|
428 k++; |
25068
53440f9bffba
disallow --gui option without GUI features (bug #53529)
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
429 } |
53440f9bffba
disallow --gui option without GUI features (bug #53529)
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
430 |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23767
diff
changeset
|
431 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
|
432 |
21783
58a4c5633efd
Disable plotting graphics when --no-window-system used (bug #48017).
Rik <rik@octave.org>
parents:
21724
diff
changeset
|
433 if (no_display) |
58a4c5633efd
Disable plotting graphics when --no-window-system used (bug #48017).
Rik <rik@octave.org>
parents:
21724
diff
changeset
|
434 { |
58a4c5633efd
Disable plotting graphics when --no-window-system used (bug #48017).
Rik <rik@octave.org>
parents:
21724
diff
changeset
|
435 start_gui = false; |
58a4c5633efd
Disable plotting graphics when --no-window-system used (bug #48017).
Rik <rik@octave.org>
parents:
21724
diff
changeset
|
436 gui_libs = false; |
58a4c5633efd
Disable plotting graphics when --no-window-system used (bug #48017).
Rik <rik@octave.org>
parents:
21724
diff
changeset
|
437 |
58a4c5633efd
Disable plotting graphics when --no-window-system used (bug #48017).
Rik <rik@octave.org>
parents:
21724
diff
changeset
|
438 file = octave_cli; |
58a4c5633efd
Disable plotting graphics when --no-window-system used (bug #48017).
Rik <rik@octave.org>
parents:
21724
diff
changeset
|
439 } |
58a4c5633efd
Disable plotting graphics when --no-window-system used (bug #48017).
Rik <rik@octave.org>
parents:
21724
diff
changeset
|
440 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
|
441 { |
19785
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
442 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
|
443 |
19785
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
444 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
|
445 |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
446 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
|
447 { |
a99b7d656a6c
start in CLI mode if display is not available (bug #40685)
John W. Eaton <jwe@octave.org>
parents:
17959
diff
changeset
|
448 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
|
449 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
|
450 |
21284
1bbd799ac7c7
Invoke correct version of octave-cli from main driver program
Mike Miller <mtmiller@octave.org>
parents:
19861
diff
changeset
|
451 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
|
452 |
a99b7d656a6c
start in CLI mode if display is not available (bug #40685)
John W. Eaton <jwe@octave.org>
parents:
17959
diff
changeset
|
453 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
|
454 { |
19785
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
455 if (! display_check_err_msg) |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
456 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
|
457 |
17994
a99b7d656a6c
start in CLI mode if display is not available (bug #40685)
John W. Eaton <jwe@octave.org>
parents:
17959
diff
changeset
|
458 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
|
459 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
|
460 } |
a99b7d656a6c
start in CLI mode if display is not available (bug #40685)
John W. Eaton <jwe@octave.org>
parents:
17959
diff
changeset
|
461 } |
a99b7d656a6c
start in CLI mode if display is not available (bug #40685)
John W. Eaton <jwe@octave.org>
parents:
17959
diff
changeset
|
462 } |
a99b7d656a6c
start in CLI mode if display is not available (bug #40685)
John W. Eaton <jwe@octave.org>
parents:
17959
diff
changeset
|
463 |
21979
d04da18a407a
use OCTAVE_USE_WINDOWS_API more consistently
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
464 #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
|
465 file += ".exe"; |
91a3858ef8cf
invoke versioned binaries from octave driver program (bug #40957)
John W. Eaton <jwe@octave.org>
parents:
18052
diff
changeset
|
466 #endif |
91a3858ef8cf
invoke versioned binaries from octave driver program (bug #40957)
John W. Eaton <jwe@octave.org>
parents:
18052
diff
changeset
|
467 |
91a3858ef8cf
invoke versioned binaries from octave driver program (bug #40957)
John W. Eaton <jwe@octave.org>
parents:
18052
diff
changeset
|
468 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
|
469 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24163
diff
changeset
|
470 // 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
|
471 // 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
|
472 // 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
|
473 // 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
|
474 // 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
|
475 // 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
|
476 // so we can forward them to the child. |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24163
diff
changeset
|
477 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24163
diff
changeset
|
478 octave_block_async_signals (); |
26826
20881d195d20
fix handling of SIGTSTP (bug #51903)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
479 octave_block_signal_by_name ("SIGTSTP"); |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24163
diff
changeset
|
480 |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
481 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
|
482 { |
23194
c897282f1ec8
always fork and exec when starting the gui (bug #49609)
John W. Eaton <jwe@octave.org>
parents:
23083
diff
changeset
|
483 // 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
|
484 // 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
|
485 // 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
|
486 // |
c897282f1ec8
always fork and exec when starting the gui (bug #49609)
John W. Eaton <jwe@octave.org>
parents:
23083
diff
changeset
|
487 // 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
|
488 // 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
|
489 // 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
|
490 // 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
|
491 // 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
|
492 |
21927
6f62bd248919
use wrapper functions for mkoctfile and main
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
493 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
|
494 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
495 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 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
|
498 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
499 retval = 1; |
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 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
|
502 { |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
503 // Child. |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
504 |
21927
6f62bd248919
use wrapper functions for mkoctfile and main
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
505 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
|
506 { |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
507 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
|
508 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
509 retval = 1; |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
510 } |
18722
f8203daed9d4
Abort Octave GUI if setsid() fails after fork().
Rik <rik@octave.org>
parents:
18361
diff
changeset
|
511 else |
f8203daed9d4
Abort Octave GUI if setsid() fails after fork().
Rik <rik@octave.org>
parents:
18361
diff
changeset
|
512 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
|
513 } |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
514 else |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
515 { |
18007
25b6fbe82827
Make the CLI the default for the 3.8 release.
Rik <rik@octave.org>
parents:
18006
diff
changeset
|
516 // 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
|
517 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24163
diff
changeset
|
518 install_signal_handlers (); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24163
diff
changeset
|
519 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24163
diff
changeset
|
520 octave_unblock_async_signals (); |
26826
20881d195d20
fix handling of SIGTSTP (bug #51903)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
521 octave_unblock_signal_by_name ("SIGTSTP"); |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24163
diff
changeset
|
522 |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
523 int status; |
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 while (true) |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
526 { |
21921
ecfcc8527661
hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents:
21783
diff
changeset
|
527 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
|
528 |
17865
dde06c2ac6c6
improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents:
17814
diff
changeset
|
529 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
|
530 { |
17865
dde06c2ac6c6
improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents:
17814
diff
changeset
|
531 int sig = caught_signal; |
dde06c2ac6c6
improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents:
17814
diff
changeset
|
532 |
dde06c2ac6c6
improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents:
17814
diff
changeset
|
533 caught_signal = -1; |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
534 |
21941
1d23b75cbcd1
hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents:
21927
diff
changeset
|
535 octave_kill_wrapper (gui_pid, sig); |
17865
dde06c2ac6c6
improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents:
17814
diff
changeset
|
536 } |
21921
ecfcc8527661
hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents:
21783
diff
changeset
|
537 else if (octave_wifexited_wrapper (status)) |
17865
dde06c2ac6c6
improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents:
17814
diff
changeset
|
538 { |
21921
ecfcc8527661
hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents:
21783
diff
changeset
|
539 retval = octave_wexitstatus_wrapper (status); |
17865
dde06c2ac6c6
improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents:
17814
diff
changeset
|
540 break; |
dde06c2ac6c6
improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents:
17814
diff
changeset
|
541 } |
21921
ecfcc8527661
hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents:
21783
diff
changeset
|
542 else if (octave_wifsignaled_wrapper (status)) |
17865
dde06c2ac6c6
improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents:
17814
diff
changeset
|
543 { |
dde06c2ac6c6
improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents:
17814
diff
changeset
|
544 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
|
545 << 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
|
546 break; |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
547 } |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
548 } |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
549 } |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
550 } |
17801
0b81d65d3c49
only fork and exec when starting gui
John W. Eaton <jwe@octave.org>
parents:
17789
diff
changeset
|
551 else |
21949
baeffde5c87d
fix build for Windows systems
John W. Eaton <jwe@octave.org>
parents:
21944
diff
changeset
|
552 { |
baeffde5c87d
fix build for Windows systems
John W. Eaton <jwe@octave.org>
parents:
21944
diff
changeset
|
553 retval = octave_exec (file, new_argv); |
baeffde5c87d
fix build for Windows systems
John W. Eaton <jwe@octave.org>
parents:
21944
diff
changeset
|
554 |
baeffde5c87d
fix build for Windows systems
John W. Eaton <jwe@octave.org>
parents:
21944
diff
changeset
|
555 if (retval < 0) |
baeffde5c87d
fix build for Windows systems
John W. Eaton <jwe@octave.org>
parents:
21944
diff
changeset
|
556 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
|
557 } |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
558 |
17813
0a887758d1cc
fix compilation of main.cc on Windows
John W. Eaton <jwe@octave.org>
parents:
17805
diff
changeset
|
559 |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
560 return retval; |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
561 } |