Mercurial > hg > octave-nkf
annotate src/main.in.cc @ 20069:6b851f6acd55
configure.ac: Remove a few more test x"" instances.
* configure.ac: Don't use x"$VAR" for testing enable_shared and enable_static.
Rewrite FFLAGS testing to use -z to avoid testing for x"". Rewrite F77 compiler
existence test to use -n to ovaid testing for x"".
author | Rik <rik@octave.org> |
---|---|
date | Wed, 25 Feb 2015 12:42:12 -0800 |
parents | 19755f4fc851 |
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 /* |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3 |
19898
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
18887
diff
changeset
|
4 Copyright (C) 2012-2015 John W. Eaton |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6 This file is part of Octave. |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
7 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
8 Octave is free software; you can redistribute it and/or modify it |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
9 under the terms of the GNU General Public License as published by the |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
10 Free Software Foundation; either version 3 of the License, or (at your |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
11 option) any later version. |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
12 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
16 for more details. |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
17 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
18 You should have received a copy of the GNU General Public License |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
19 along with Octave; see the file COPYING. If not, see |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
20 <http://www.gnu.org/licenses/>. |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
21 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
22 */ |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
23 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
24 // 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
|
25 // 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
|
26 // 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
|
27 // 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
|
28 // 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
|
29 // liboctave or libinterp. |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
30 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 #ifdef HAVE_CONFIG_H |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
32 #include <config.h> |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
33 #endif |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
34 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
35 #include <cstdlib> |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
36 #include <cstring> |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
37 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
38 #include <algorithm> |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
39 #include <iostream> |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
40 #include <string> |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
41 |
17805
2a15970da7f0
allow main.cc to build again with --disable-gui
John W. Eaton <jwe@octave.org>
parents:
17803
diff
changeset
|
42 #include <sys/types.h> |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
43 #include <unistd.h> |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
44 |
18151
91a3858ef8cf
invoke versioned binaries from octave driver program (bug #40957)
John W. Eaton <jwe@octave.org>
parents:
18052
diff
changeset
|
45 #ifndef OCTAVE_VERSION |
91a3858ef8cf
invoke versioned binaries from octave driver program (bug #40957)
John W. Eaton <jwe@octave.org>
parents:
18052
diff
changeset
|
46 #define OCTAVE_VERSION %OCTAVE_VERSION% |
91a3858ef8cf
invoke versioned binaries from octave driver program (bug #40957)
John W. Eaton <jwe@octave.org>
parents:
18052
diff
changeset
|
47 #endif |
91a3858ef8cf
invoke versioned binaries from octave driver program (bug #40957)
John W. Eaton <jwe@octave.org>
parents:
18052
diff
changeset
|
48 |
18162
65e4e0569ed4
install octave-gui binary in libexec directory
John W. Eaton <jwe@octave.org>
parents:
18151
diff
changeset
|
49 #ifndef OCTAVE_ARCHLIBDIR |
65e4e0569ed4
install octave-gui binary in libexec directory
John W. Eaton <jwe@octave.org>
parents:
18151
diff
changeset
|
50 #define OCTAVE_ARCHLIBDIR %OCTAVE_ARCHLIBDIR% |
65e4e0569ed4
install octave-gui binary in libexec directory
John W. Eaton <jwe@octave.org>
parents:
18151
diff
changeset
|
51 #endif |
65e4e0569ed4
install octave-gui binary in libexec directory
John W. Eaton <jwe@octave.org>
parents:
18151
diff
changeset
|
52 |
18151
91a3858ef8cf
invoke versioned binaries from octave driver program (bug #40957)
John W. Eaton <jwe@octave.org>
parents:
18052
diff
changeset
|
53 #ifndef OCTAVE_BINDIR |
91a3858ef8cf
invoke versioned binaries from octave driver program (bug #40957)
John W. Eaton <jwe@octave.org>
parents:
18052
diff
changeset
|
54 #define OCTAVE_BINDIR %OCTAVE_BINDIR% |
91a3858ef8cf
invoke versioned binaries from octave driver program (bug #40957)
John W. Eaton <jwe@octave.org>
parents:
18052
diff
changeset
|
55 #endif |
91a3858ef8cf
invoke versioned binaries from octave driver program (bug #40957)
John W. Eaton <jwe@octave.org>
parents:
18052
diff
changeset
|
56 |
91a3858ef8cf
invoke versioned binaries from octave driver program (bug #40957)
John W. Eaton <jwe@octave.org>
parents:
18052
diff
changeset
|
57 #ifndef OCTAVE_PREFIX |
91a3858ef8cf
invoke versioned binaries from octave driver program (bug #40957)
John W. Eaton <jwe@octave.org>
parents:
18052
diff
changeset
|
58 #define OCTAVE_PREFIX %OCTAVE_PREFIX% |
91a3858ef8cf
invoke versioned binaries from octave driver program (bug #40957)
John W. Eaton <jwe@octave.org>
parents:
18052
diff
changeset
|
59 #endif |
91a3858ef8cf
invoke versioned binaries from octave driver program (bug #40957)
John W. Eaton <jwe@octave.org>
parents:
18052
diff
changeset
|
60 |
19990
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
19898
diff
changeset
|
61 #include "display-available.h" |
18428
f1ee47866e6b
use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
18162
diff
changeset
|
62 #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
|
63 |
17994
a99b7d656a6c
start in CLI mode if display is not available (bug #40685)
John W. Eaton <jwe@octave.org>
parents:
17959
diff
changeset
|
64 #include <cstdlib> |
a99b7d656a6c
start in CLI mode if display is not available (bug #40685)
John W. Eaton <jwe@octave.org>
parents:
17959
diff
changeset
|
65 |
17814
e50a3664bd45
make compilation of main.cc work again when not building GUI
John W. Eaton <jwe@octave.org>
parents:
17813
diff
changeset
|
66 #if (defined (HAVE_OCTAVE_GUI) \ |
e50a3664bd45
make compilation of main.cc work again when not building GUI
John W. Eaton <jwe@octave.org>
parents:
17813
diff
changeset
|
67 && ! defined (__WIN32__) || defined (__CYGWIN__)) |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
68 |
17780
8b353af4a1ca
allow octave main program to work on Windows systems
John W. Eaton <jwe@octave.org>
parents:
17778
diff
changeset
|
69 #include <signal.h> |
17813
0a887758d1cc
fix compilation of main.cc on Windows
John W. Eaton <jwe@octave.org>
parents:
17805
diff
changeset
|
70 #include <fcntl.h> |
0a887758d1cc
fix compilation of main.cc on Windows
John W. Eaton <jwe@octave.org>
parents:
17805
diff
changeset
|
71 |
0a887758d1cc
fix compilation of main.cc on Windows
John W. Eaton <jwe@octave.org>
parents:
17805
diff
changeset
|
72 // This is a liboctave header, but it doesn't include any other Octave |
0a887758d1cc
fix compilation of main.cc on Windows
John W. Eaton <jwe@octave.org>
parents:
17805
diff
changeset
|
73 // headers or declare any functions that are defined in liboctave. |
0a887758d1cc
fix compilation of main.cc on Windows
John W. Eaton <jwe@octave.org>
parents:
17805
diff
changeset
|
74 #include "syswait.h" |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
75 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
76 typedef void sig_handler (int); |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
77 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
78 // Forward signals to the GUI process. |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
79 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
80 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
|
81 |
17865
dde06c2ac6c6
improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents:
17814
diff
changeset
|
82 static int caught_signal = -1; |
dde06c2ac6c6
improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents:
17814
diff
changeset
|
83 |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
84 static void |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
85 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
|
86 { |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
87 if (gui_pid > 0) |
17865
dde06c2ac6c6
improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents:
17814
diff
changeset
|
88 caught_signal = sig; |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
89 } |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
90 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
91 static sig_handler * |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
92 octave_set_signal_handler (int sig, sig_handler *handler) |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
93 { |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
94 struct sigaction act, oact; |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
95 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
96 act.sa_handler = handler; |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
97 act.sa_flags = 0; |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
98 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
99 gnulib::sigemptyset (&act.sa_mask); |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
100 gnulib::sigemptyset (&oact.sa_mask); |
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 gnulib::sigaction (sig, &act, &oact); |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
103 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
104 return oact.sa_handler; |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
105 } |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
106 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
107 static void |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
108 install_signal_handlers (void) |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
109 { |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
110 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
111 #ifdef SIGINT |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
112 octave_set_signal_handler (SIGINT, gui_driver_sig_handler); |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
113 #endif |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
114 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
115 #ifdef SIGBREAK |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
116 octave_set_signal_handler (SIGBREAK, gui_driver_sig_handler); |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
117 #endif |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
118 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
119 #ifdef SIGABRT |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
120 octave_set_signal_handler (SIGABRT, gui_driver_sig_handler); |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
121 #endif |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
122 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
123 #ifdef SIGALRM |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
124 octave_set_signal_handler (SIGALRM, gui_driver_sig_handler); |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
125 #endif |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
126 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
127 #ifdef SIGBUS |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
128 octave_set_signal_handler (SIGBUS, gui_driver_sig_handler); |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
129 #endif |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
130 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
131 // SIGCHLD |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
132 // SIGCLD |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
133 // SIGCONT |
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 #ifdef SIGEMT |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
136 octave_set_signal_handler (SIGEMT, gui_driver_sig_handler); |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
137 #endif |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
138 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
139 #ifdef SIGFPE |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
140 octave_set_signal_handler (SIGFPE, gui_driver_sig_handler); |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
141 #endif |
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 #ifdef SIGHUP |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
144 octave_set_signal_handler (SIGHUP, gui_driver_sig_handler); |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
145 #endif |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
146 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
147 #ifdef SIGILL |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
148 octave_set_signal_handler (SIGILL, gui_driver_sig_handler); |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
149 #endif |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
150 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
151 // SIGINFO |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
152 // SIGINT |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
153 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
154 #ifdef SIGIOT |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
155 octave_set_signal_handler (SIGIOT, gui_driver_sig_handler); |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
156 #endif |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
157 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
158 #ifdef SIGLOST |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
159 octave_set_signal_handler (SIGLOST, gui_driver_sig_handler); |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
160 #endif |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
161 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
162 #ifdef SIGPIPE |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
163 octave_set_signal_handler (SIGPIPE, gui_driver_sig_handler); |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
164 #endif |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
165 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
166 #ifdef SIGPOLL |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
167 octave_set_signal_handler (SIGPOLL, gui_driver_sig_handler); |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
168 #endif |
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 // SIGPROF |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
171 // SIGPWR |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
172 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
173 #ifdef SIGQUIT |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
174 octave_set_signal_handler (SIGQUIT, gui_driver_sig_handler); |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
175 #endif |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
176 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
177 #ifdef SIGSEGV |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
178 octave_set_signal_handler (SIGSEGV, gui_driver_sig_handler); |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
179 #endif |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
180 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
181 // SIGSTOP |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
182 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
183 #ifdef SIGSYS |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
184 octave_set_signal_handler (SIGSYS, gui_driver_sig_handler); |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
185 #endif |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
186 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
187 #ifdef SIGTERM |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
188 octave_set_signal_handler (SIGTERM, gui_driver_sig_handler); |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
189 #endif |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
190 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
191 #ifdef SIGTRAP |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
192 octave_set_signal_handler (SIGTRAP, gui_driver_sig_handler); |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
193 #endif |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
194 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
195 // SIGTSTP |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
196 // SIGTTIN |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
197 // SIGTTOU |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
198 // SIGURG |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
199 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
200 #ifdef SIGUSR1 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
201 octave_set_signal_handler (SIGUSR1, gui_driver_sig_handler); |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
202 #endif |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
203 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
204 #ifdef SIGUSR2 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
205 octave_set_signal_handler (SIGUSR2, gui_driver_sig_handler); |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
206 #endif |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
207 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
208 #ifdef SIGVTALRM |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
209 octave_set_signal_handler (SIGVTALRM, gui_driver_sig_handler); |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
210 #endif |
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 #ifdef SIGIO |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
213 octave_set_signal_handler (SIGIO, gui_driver_sig_handler); |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
214 #endif |
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 // SIGWINCH |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
217 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
218 #ifdef SIGXCPU |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
219 octave_set_signal_handler (SIGXCPU, gui_driver_sig_handler); |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
220 #endif |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
221 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
222 #ifdef SIGXFSZ |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
223 octave_set_signal_handler (SIGXFSZ, gui_driver_sig_handler); |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
224 #endif |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
225 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
226 } |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
227 |
17803
f5ada8597078
* main.in.cc (have_controlling_terminal): Return bool, not int.
John W. Eaton <jwe@octave.org>
parents:
17802
diff
changeset
|
228 static bool |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
229 have_controlling_terminal (void) |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
230 { |
17803
f5ada8597078
* main.in.cc (have_controlling_terminal): Return bool, not int.
John W. Eaton <jwe@octave.org>
parents:
17802
diff
changeset
|
231 int retval = false; |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
232 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
233 #if defined (HAVE_CTERMID) |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
234 const char *ctty = ctermid (0); |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
235 #else |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
236 const char *ctty = "/dev/tty"; |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
237 #endif |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
238 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
239 int fd = gnulib::open (ctty, O_RDWR, 0); |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
240 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
241 if (fd >= 0) |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
242 { |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
243 gnulib::close (fd); |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
244 |
17803
f5ada8597078
* main.in.cc (have_controlling_terminal): Return bool, not int.
John W. Eaton <jwe@octave.org>
parents:
17802
diff
changeset
|
245 retval = true; |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
246 } |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
247 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
248 return retval; |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
249 } |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
250 |
17813
0a887758d1cc
fix compilation of main.cc on Windows
John W. Eaton <jwe@octave.org>
parents:
17805
diff
changeset
|
251 #endif |
0a887758d1cc
fix compilation of main.cc on Windows
John W. Eaton <jwe@octave.org>
parents:
17805
diff
changeset
|
252 |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
253 static std::string |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
254 get_octave_bindir (void) |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
255 { |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
256 // 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
|
257 // 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
|
258 // 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
|
259 // one originally configured. |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
260 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
261 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
|
262 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
263 return obd.empty () ? subst_octave_home (std::string (OCTAVE_BINDIR)) : obd; |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
264 } |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
265 |
18162
65e4e0569ed4
install octave-gui binary in libexec directory
John W. Eaton <jwe@octave.org>
parents:
18151
diff
changeset
|
266 static std::string |
65e4e0569ed4
install octave-gui binary in libexec directory
John W. Eaton <jwe@octave.org>
parents:
18151
diff
changeset
|
267 get_octave_archlibdir (void) |
65e4e0569ed4
install octave-gui binary in libexec directory
John W. Eaton <jwe@octave.org>
parents:
18151
diff
changeset
|
268 { |
65e4e0569ed4
install octave-gui binary in libexec directory
John W. Eaton <jwe@octave.org>
parents:
18151
diff
changeset
|
269 // Accept value from the environment literally, but substitute |
65e4e0569ed4
install octave-gui binary in libexec directory
John W. Eaton <jwe@octave.org>
parents:
18151
diff
changeset
|
270 // 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:
18151
diff
changeset
|
271 // 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:
18151
diff
changeset
|
272 // the one originally configured. |
65e4e0569ed4
install octave-gui binary in libexec directory
John W. Eaton <jwe@octave.org>
parents:
18151
diff
changeset
|
273 |
65e4e0569ed4
install octave-gui binary in libexec directory
John W. Eaton <jwe@octave.org>
parents:
18151
diff
changeset
|
274 std::string dir = octave_getenv ("OCTAVE_ARCHLIBDIR"); |
65e4e0569ed4
install octave-gui binary in libexec directory
John W. Eaton <jwe@octave.org>
parents:
18151
diff
changeset
|
275 |
20068
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19990
diff
changeset
|
276 return dir.empty () ? subst_octave_home (std::string (OCTAVE_ARCHLIBDIR)) |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19990
diff
changeset
|
277 : dir; |
18162
65e4e0569ed4
install octave-gui binary in libexec directory
John W. Eaton <jwe@octave.org>
parents:
18151
diff
changeset
|
278 } |
65e4e0569ed4
install octave-gui binary in libexec directory
John W. Eaton <jwe@octave.org>
parents:
18151
diff
changeset
|
279 |
18006
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
280 // Adapted from libtool wrapper. |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
281 #if defined (__WIN32__) && ! defined (__CYGWIN__) |
17959
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
282 |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
283 /* Prepares an argument vector before calling spawn(). |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
284 Note that spawn() does not by itself call the command interpreter |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
285 (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
286 ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
287 GetVersionEx(&v); |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
288 v.dwPlatformId == VER_PLATFORM_WIN32_NT; |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
289 }) ? "cmd.exe" : "command.com"). |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
290 Instead it simply concatenates the arguments, separated by ' ', and calls |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
291 CreateProcess(). We must quote the arguments since Win32 CreateProcess() |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
292 interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
293 special way: |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
294 - Space and tab are interpreted as delimiters. They are not treated as |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
295 delimiters if they are surrounded by double quotes: "...". |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
296 - Unescaped double quotes are removed from the input. Their only effect is |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
297 that within double quotes, space and tab are treated like normal |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
298 characters. |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
299 - Backslashes not followed by double quotes are not special. |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
300 - But 2*n+1 backslashes followed by a double quote become |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
301 n backslashes followed by a double quote (n >= 0): |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
302 \" -> " |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
303 \\\" -> \" |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
304 \\\\\" -> \\" |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
305 */ |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
306 #define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
307 #define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
308 char ** |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
309 prepare_spawn (char **argv) |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
310 { |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
311 size_t argc; |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
312 char **new_argv; |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
313 size_t i; |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
314 |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
315 /* Count number of arguments. */ |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
316 for (argc = 0; argv[argc] != NULL; argc++) |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
317 ; |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
318 |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
319 /* Allocate new argument vector. */ |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
320 new_argv = new char* [argc + 1]; |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
321 |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
322 /* Put quoted arguments into the new argument vector. */ |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
323 for (i = 0; i < argc; i++) |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
324 { |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
325 const char *string = argv[i]; |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
326 |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
327 if (string[0] == '\0') |
18006
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
328 new_argv[i] = strdup ("\"\""); |
17959
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
329 else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) |
18006
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
330 { |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
331 int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
332 size_t length; |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
333 unsigned int backslashes; |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
334 const char *s; |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
335 char *quoted_string; |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
336 char *p; |
17959
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
337 |
18006
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
338 length = 0; |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
339 backslashes = 0; |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
340 if (quote_around) |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
341 length++; |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
342 for (s = string; *s != '\0'; s++) |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
343 { |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
344 char c = *s; |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
345 if (c == '"') |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
346 length += backslashes + 1; |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
347 length++; |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
348 if (c == '\\') |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
349 backslashes++; |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
350 else |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
351 backslashes = 0; |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
352 } |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
353 if (quote_around) |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
354 length += backslashes + 1; |
17959
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
355 |
18006
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
356 quoted_string = new char [length + 1]; |
17959
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
357 |
18006
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
358 p = quoted_string; |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
359 backslashes = 0; |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
360 if (quote_around) |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
361 *p++ = '"'; |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
362 for (s = string; *s != '\0'; s++) |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
363 { |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
364 char c = *s; |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
365 if (c == '"') |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
366 { |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
367 unsigned int j; |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
368 for (j = backslashes + 1; j > 0; j--) |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
369 *p++ = '\\'; |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
370 } |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
371 *p++ = c; |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
372 if (c == '\\') |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
373 backslashes++; |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
374 else |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
375 backslashes = 0; |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
376 } |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
377 if (quote_around) |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
378 { |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
379 unsigned int j; |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
380 for (j = backslashes; j > 0; j--) |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
381 *p++ = '\\'; |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
382 *p++ = '"'; |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
383 } |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
384 *p = '\0'; |
17959
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
385 |
18006
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
386 new_argv[i] = quoted_string; |
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
387 } |
17959
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
388 else |
18006
b992a17767fe
main.in.cc: Replace tabs with spaces. Shorten lines > 80 chars.
Rik <rik@octave.org>
parents:
17994
diff
changeset
|
389 new_argv[i] = (char *) string; |
17959
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
390 } |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
391 new_argv[argc] = NULL; |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
392 |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
393 return new_argv; |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
394 } |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
395 |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
396 #endif // __WIN32__ && ! __CYGWIN__ |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
397 |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
398 static int |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
399 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
|
400 { |
17959
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
401 #if defined (__WIN32__) && ! defined (__CYGWIN__) |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
402 argv = prepare_spawn (argv); |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
403 return _spawnv (_P_WAIT, file.c_str (), argv); |
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
404 #else |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
405 execv (file.c_str (), argv); |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
406 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
407 std::cerr << "octave: failed to exec '" << file << "'" << std::endl; |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
408 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
409 return 1; |
17959
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
410 #endif |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
411 } |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
412 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
413 static char * |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
414 strsave (const char *s) |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
415 { |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
416 if (! s) |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
417 return 0; |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
418 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
419 int len = strlen (s); |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
420 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
|
421 tmp = strcpy (tmp, s); |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
422 return tmp; |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
423 } |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
424 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
425 int |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
426 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
|
427 { |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
428 int retval = 0; |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
429 |
18014
6df05f2fd354
maint: Back out changeset 25b6fbe82827 and set default to GUI for 4.0 release.
Rik <rik@octave.org>
parents:
18008
diff
changeset
|
430 bool start_gui = true; |
6df05f2fd354
maint: Back out changeset 25b6fbe82827 and set default to GUI for 4.0 release.
Rik <rik@octave.org>
parents:
18008
diff
changeset
|
431 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
|
432 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
433 std::string octave_bindir = get_octave_bindir (); |
18162
65e4e0569ed4
install octave-gui binary in libexec directory
John W. Eaton <jwe@octave.org>
parents:
18151
diff
changeset
|
434 std::string octave_archlibdir = get_octave_archlibdir (); |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
435 |
18014
6df05f2fd354
maint: Back out changeset 25b6fbe82827 and set default to GUI for 4.0 release.
Rik <rik@octave.org>
parents:
18008
diff
changeset
|
436 #if defined (HAVE_OCTAVE_GUI) |
18163
eb51f47d9dee
maint: Periodic merge of stable to gui-release.
John W. Eaton <jwe@octave.org>
diff
changeset
|
437 // 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
|
438 // octave_archlibdir directory name so we don't need to append it to |
eb51f47d9dee
maint: Periodic merge of stable to gui-release.
John W. Eaton <jwe@octave.org>
diff
changeset
|
439 // the octave-gui file name. |
eb51f47d9dee
maint: Periodic merge of stable to gui-release.
John W. Eaton <jwe@octave.org>
diff
changeset
|
440 |
eb51f47d9dee
maint: Periodic merge of stable to gui-release.
John W. Eaton <jwe@octave.org>
diff
changeset
|
441 std::string file = octave_archlibdir + dir_sep_char + "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
|
442 #else |
18151
91a3858ef8cf
invoke versioned binaries from octave driver program (bug #40957)
John W. Eaton <jwe@octave.org>
parents:
18052
diff
changeset
|
443 std::string file |
18163
eb51f47d9dee
maint: Periodic merge of stable to gui-release.
John W. Eaton <jwe@octave.org>
diff
changeset
|
444 = octave_bindir + dir_sep_char + "octave-cli-" OCTAVE_VERSION; |
18014
6df05f2fd354
maint: Back out changeset 25b6fbe82827 and set default to GUI for 4.0 release.
Rik <rik@octave.org>
parents:
18008
diff
changeset
|
445 #endif |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
446 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
447 char **new_argv = new char * [argc + 1]; |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
448 |
17959
1329866151be
[Win32] Use spawn instead of exec for main octave wrapper executable.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17865
diff
changeset
|
449 int k = 1; |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
450 |
17994
a99b7d656a6c
start in CLI mode if display is not available (bug #40685)
John W. Eaton <jwe@octave.org>
parents:
17959
diff
changeset
|
451 bool warn_display = true; |
a99b7d656a6c
start in CLI mode if display is not available (bug #40685)
John W. Eaton <jwe@octave.org>
parents:
17959
diff
changeset
|
452 |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
453 for (int i = 1; i < argc; i++) |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
454 { |
18014
6df05f2fd354
maint: Back out changeset 25b6fbe82827 and set default to GUI for 4.0 release.
Rik <rik@octave.org>
parents:
18008
diff
changeset
|
455 if (! strcmp (argv[i], "--no-gui-libs")) |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
456 { |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
457 // Run the version of Octave that is not linked with any GUI |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
458 // libraries. It may not be possible to do plotting or any |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
459 // ui* calls, but it will be a little faster to start and |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
460 // require less memory. Don't pass the --no-gui-libs option |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
461 // on as that option is not recognized by Octave. |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
462 |
18014
6df05f2fd354
maint: Back out changeset 25b6fbe82827 and set default to GUI for 4.0 release.
Rik <rik@octave.org>
parents:
18008
diff
changeset
|
463 start_gui = false; |
6df05f2fd354
maint: Back out changeset 25b6fbe82827 and set default to GUI for 4.0 release.
Rik <rik@octave.org>
parents:
18008
diff
changeset
|
464 gui_libs = false; |
6df05f2fd354
maint: Back out changeset 25b6fbe82827 and set default to GUI for 4.0 release.
Rik <rik@octave.org>
parents:
18008
diff
changeset
|
465 file = octave_bindir + dir_sep_char + "octave-cli"; |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
466 } |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
467 else if (! strcmp (argv[i], "--no-gui")) |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
468 { |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
469 // If we see this option, then we can just exec octave; we |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
470 // don't have to create a child process and wait for it to |
18151
91a3858ef8cf
invoke versioned binaries from octave driver program (bug #40957)
John W. Eaton <jwe@octave.org>
parents:
18052
diff
changeset
|
471 // exit. But do exec "octave-gui", not "octave-cli", because |
91a3858ef8cf
invoke versioned binaries from octave driver program (bug #40957)
John W. Eaton <jwe@octave.org>
parents:
18052
diff
changeset
|
472 // even if the --no-gui option is given, we may be asked to do |
91a3858ef8cf
invoke versioned binaries from octave driver program (bug #40957)
John W. Eaton <jwe@octave.org>
parents:
18052
diff
changeset
|
473 // some plotting or ui* calls. |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
474 |
18014
6df05f2fd354
maint: Back out changeset 25b6fbe82827 and set default to GUI for 4.0 release.
Rik <rik@octave.org>
parents:
18008
diff
changeset
|
475 start_gui = false; |
6df05f2fd354
maint: Back out changeset 25b6fbe82827 and set default to GUI for 4.0 release.
Rik <rik@octave.org>
parents:
18008
diff
changeset
|
476 new_argv[k++] = argv[i]; |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
477 } |
18008
2831a949a219
Restore passing '--silent' option from octave wrapper executable
Mike Miller <mtmiller@ieee.org>
parents:
18007
diff
changeset
|
478 else if (! strcmp (argv[i], "--silent") || ! strcmp (argv[i], "--quiet") |
2831a949a219
Restore passing '--silent' option from octave wrapper executable
Mike Miller <mtmiller@ieee.org>
parents:
18007
diff
changeset
|
479 || ! strcmp (argv[i], "-q")) |
18010
dc58d4810de6
main.in.cc: Respect --silent option and don't print startup message.
Rik <rik@octave.org>
parents:
18007
diff
changeset
|
480 { |
dc58d4810de6
main.in.cc: Respect --silent option and don't print startup message.
Rik <rik@octave.org>
parents:
18007
diff
changeset
|
481 warn_display = false; |
dc58d4810de6
main.in.cc: Respect --silent option and don't print startup message.
Rik <rik@octave.org>
parents:
18007
diff
changeset
|
482 new_argv[k++] = argv[i]; |
dc58d4810de6
main.in.cc: Respect --silent option and don't print startup message.
Rik <rik@octave.org>
parents:
18007
diff
changeset
|
483 } |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
484 else |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
485 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
|
486 } |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
487 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
488 new_argv[k] = 0; |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
489 |
17994
a99b7d656a6c
start in CLI mode if display is not available (bug #40685)
John W. Eaton <jwe@octave.org>
parents:
17959
diff
changeset
|
490 if (gui_libs || start_gui) |
a99b7d656a6c
start in CLI mode if display is not available (bug #40685)
John W. Eaton <jwe@octave.org>
parents:
17959
diff
changeset
|
491 { |
19990
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
19898
diff
changeset
|
492 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
|
493 |
19990
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
19898
diff
changeset
|
494 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:
19898
diff
changeset
|
495 |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
19898
diff
changeset
|
496 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
|
497 { |
a99b7d656a6c
start in CLI mode if display is not available (bug #40685)
John W. Eaton <jwe@octave.org>
parents:
17959
diff
changeset
|
498 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
|
499 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
|
500 |
18151
91a3858ef8cf
invoke versioned binaries from octave driver program (bug #40957)
John W. Eaton <jwe@octave.org>
parents:
18052
diff
changeset
|
501 file = octave_bindir + dir_sep_char + "octave-cli-" OCTAVE_VERSION; |
17994
a99b7d656a6c
start in CLI mode if display is not available (bug #40685)
John W. Eaton <jwe@octave.org>
parents:
17959
diff
changeset
|
502 |
a99b7d656a6c
start in CLI mode if display is not available (bug #40685)
John W. Eaton <jwe@octave.org>
parents:
17959
diff
changeset
|
503 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
|
504 { |
19990
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
19898
diff
changeset
|
505 if (! display_check_err_msg) |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
19898
diff
changeset
|
506 display_check_err_msg = "graphical display unavailable"; |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
19898
diff
changeset
|
507 |
17994
a99b7d656a6c
start in CLI mode if display is not available (bug #40685)
John W. Eaton <jwe@octave.org>
parents:
17959
diff
changeset
|
508 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
|
509 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
|
510 } |
a99b7d656a6c
start in CLI mode if display is not available (bug #40685)
John W. Eaton <jwe@octave.org>
parents:
17959
diff
changeset
|
511 } |
a99b7d656a6c
start in CLI mode if display is not available (bug #40685)
John W. Eaton <jwe@octave.org>
parents:
17959
diff
changeset
|
512 } |
a99b7d656a6c
start in CLI mode if display is not available (bug #40685)
John W. Eaton <jwe@octave.org>
parents:
17959
diff
changeset
|
513 |
18151
91a3858ef8cf
invoke versioned binaries from octave driver program (bug #40957)
John W. Eaton <jwe@octave.org>
parents:
18052
diff
changeset
|
514 #if defined (__WIN32__) && ! defined (__CYGWIN__) |
91a3858ef8cf
invoke versioned binaries from octave driver program (bug #40957)
John W. Eaton <jwe@octave.org>
parents:
18052
diff
changeset
|
515 file += ".exe"; |
91a3858ef8cf
invoke versioned binaries from octave driver program (bug #40957)
John W. Eaton <jwe@octave.org>
parents:
18052
diff
changeset
|
516 #endif |
91a3858ef8cf
invoke versioned binaries from octave driver program (bug #40957)
John W. Eaton <jwe@octave.org>
parents:
18052
diff
changeset
|
517 |
91a3858ef8cf
invoke versioned binaries from octave driver program (bug #40957)
John W. Eaton <jwe@octave.org>
parents:
18052
diff
changeset
|
518 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
|
519 |
17814
e50a3664bd45
make compilation of main.cc work again when not building GUI
John W. Eaton <jwe@octave.org>
parents:
17813
diff
changeset
|
520 #if (defined (HAVE_OCTAVE_GUI) \ |
e50a3664bd45
make compilation of main.cc work again when not building GUI
John W. Eaton <jwe@octave.org>
parents:
17813
diff
changeset
|
521 && ! defined (__WIN32__) || defined (__CYGWIN__)) |
17813
0a887758d1cc
fix compilation of main.cc on Windows
John W. Eaton <jwe@octave.org>
parents:
17805
diff
changeset
|
522 |
17801
0b81d65d3c49
only fork and exec when starting gui
John W. Eaton <jwe@octave.org>
parents:
17789
diff
changeset
|
523 if (gui_libs && start_gui && have_controlling_terminal ()) |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
524 { |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
525 install_signal_handlers (); |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
526 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
527 gui_pid = fork (); |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
528 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
529 if (gui_pid < 0) |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
530 { |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
531 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
|
532 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
533 retval = 1; |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
534 } |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
535 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
|
536 { |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
537 // Child. |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
538 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
539 if (setsid () < 0) |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
540 { |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
541 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
|
542 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
543 retval = 1; |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
544 } |
18887
f8203daed9d4
Abort Octave GUI if setsid() fails after fork().
Rik <rik@octave.org>
parents:
18429
diff
changeset
|
545 else |
f8203daed9d4
Abort Octave GUI if setsid() fails after fork().
Rik <rik@octave.org>
parents:
18429
diff
changeset
|
546 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
|
547 } |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
548 else |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
549 { |
18007
25b6fbe82827
Make the CLI the default for the 3.8 release.
Rik <rik@octave.org>
parents:
18006
diff
changeset
|
550 // 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
|
551 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
552 int status; |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
553 |
17865
dde06c2ac6c6
improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents:
17814
diff
changeset
|
554 while (true) |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
555 { |
17780
8b353af4a1ca
allow octave main program to work on Windows systems
John W. Eaton <jwe@octave.org>
parents:
17778
diff
changeset
|
556 WAITPID (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
|
557 |
17865
dde06c2ac6c6
improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents:
17814
diff
changeset
|
558 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
|
559 { |
17865
dde06c2ac6c6
improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents:
17814
diff
changeset
|
560 int sig = caught_signal; |
dde06c2ac6c6
improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents:
17814
diff
changeset
|
561 |
dde06c2ac6c6
improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents:
17814
diff
changeset
|
562 caught_signal = -1; |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
563 |
17865
dde06c2ac6c6
improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents:
17814
diff
changeset
|
564 kill (gui_pid, sig); |
dde06c2ac6c6
improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents:
17814
diff
changeset
|
565 } |
dde06c2ac6c6
improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents:
17814
diff
changeset
|
566 else if (WIFEXITED (status)) |
dde06c2ac6c6
improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents:
17814
diff
changeset
|
567 { |
dde06c2ac6c6
improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents:
17814
diff
changeset
|
568 retval = WEXITSTATUS (status); |
dde06c2ac6c6
improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents:
17814
diff
changeset
|
569 break; |
dde06c2ac6c6
improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents:
17814
diff
changeset
|
570 } |
dde06c2ac6c6
improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents:
17814
diff
changeset
|
571 else if (WIFSIGNALLED (status)) |
dde06c2ac6c6
improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents:
17814
diff
changeset
|
572 { |
dde06c2ac6c6
improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents:
17814
diff
changeset
|
573 std::cerr << "octave exited with signal " |
dde06c2ac6c6
improve signal handling in driver program
John W. Eaton <jwe@octave.org>
parents:
17814
diff
changeset
|
574 << WTERMSIG (status) << std::endl; |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
575 break; |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
576 } |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
577 } |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
578 } |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
579 } |
17801
0b81d65d3c49
only fork and exec when starting gui
John W. Eaton <jwe@octave.org>
parents:
17789
diff
changeset
|
580 else |
0b81d65d3c49
only fork and exec when starting gui
John W. Eaton <jwe@octave.org>
parents:
17789
diff
changeset
|
581 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
|
582 |
17813
0a887758d1cc
fix compilation of main.cc on Windows
John W. Eaton <jwe@octave.org>
parents:
17805
diff
changeset
|
583 #else |
0a887758d1cc
fix compilation of main.cc on Windows
John W. Eaton <jwe@octave.org>
parents:
17805
diff
changeset
|
584 |
0a887758d1cc
fix compilation of main.cc on Windows
John W. Eaton <jwe@octave.org>
parents:
17805
diff
changeset
|
585 retval = octave_exec (file, new_argv); |
0a887758d1cc
fix compilation of main.cc on Windows
John W. Eaton <jwe@octave.org>
parents:
17805
diff
changeset
|
586 |
0a887758d1cc
fix compilation of main.cc on Windows
John W. Eaton <jwe@octave.org>
parents:
17805
diff
changeset
|
587 #endif |
0a887758d1cc
fix compilation of main.cc on Windows
John W. Eaton <jwe@octave.org>
parents:
17805
diff
changeset
|
588 |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
589 return retval; |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
590 } |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
591 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
592 /*! |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
593 @mainpage Source code documentation for GNU Octave |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
594 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
595 GNU Octave is a high-level language, primarily intended for numerical |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
596 computations. It provides a convenient interactive command line |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
597 interface for solving linear and nonlinear problems numerically, and |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
598 for performing other numerical experiments. It may also be used as a |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
599 batch-oriented language for data processing. |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
600 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
601 GNU Octave is free software. You may redistribute it and/or modify it |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
602 under the terms of the <a href="http://www.gnu.org/licenses/">GNU |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
603 General Public License</a> as published by the Free Software Foundation. |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
604 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
605 This is the developer documentation for Octave's own source code. It is |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
606 intended to help for hacking Octave. It may also be useful for |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
607 understanding the Octave API when writing your own .oct files. |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
608 */ |