annotate liboctave/wrappers/signal-wrappers.c @ 23084:ef4d915df748

maint: Merge stable to default.
author John W. Eaton <jwe@octave.org>
date Mon, 23 Jan 2017 14:27:48 -0500
parents 3a2b891d0b33 e9a0469dedd9
children 092078913d54
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
21938
da9b960b1b2d use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1 /*
da9b960b1b2d use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2
da9b960b1b2d use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents:
diff changeset
3 Copyright (C) 2016 John W. Eaton
da9b960b1b2d use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4
da9b960b1b2d use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents:
diff changeset
5 This file is part of Octave.
da9b960b1b2d use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6
da9b960b1b2d use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
8 under the terms of the GNU General Public License as published by
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
9 the Free Software Foundation; either version 3 of the License, or
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
10 (at your option) any later version.
21938
da9b960b1b2d use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
12 Octave is distributed in the hope that it will be useful, but
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
13 WITHOUT ANY WARRANTY; without even the implied warranty of
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
15 GNU General Public License for more details.
21938
da9b960b1b2d use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16
da9b960b1b2d use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
da9b960b1b2d use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, see
da9b960b1b2d use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents:
diff changeset
19 <http://www.gnu.org/licenses/>.
da9b960b1b2d use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents:
diff changeset
20
da9b960b1b2d use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents:
diff changeset
21 */
da9b960b1b2d use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22
da9b960b1b2d use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents:
diff changeset
23 // These functions may be provided by gnulib. We don't include gnulib
da9b960b1b2d use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents:
diff changeset
24 // headers directly in Octave's C++ source files to avoid problems that
da9b960b1b2d use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25 // may be caused by the way that gnulib overrides standard library
da9b960b1b2d use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26 // functions.
da9b960b1b2d use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27
da9b960b1b2d use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 #if defined (HAVE_CONFIG_H)
da9b960b1b2d use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29 # include "config.h"
da9b960b1b2d use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30 #endif
da9b960b1b2d use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31
da9b960b1b2d use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 #include <sys/types.h>
da9b960b1b2d use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33 #include <signal.h>
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
34 #include <stdlib.h>
21938
da9b960b1b2d use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35 #include <string.h>
da9b960b1b2d use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
37 #if defined (__WIN32__) && ! defined (__CYGWIN__)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
38 # include <windows.h>
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
39 #else
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
40 # include <pthread.h>
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
41 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
42
21938
da9b960b1b2d use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 #include "signal-wrappers.h"
da9b960b1b2d use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents:
diff changeset
44
21940
70824a0dd009 provide wrapper for kill
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
45 int
70824a0dd009 provide wrapper for kill
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
46 octave_kill_wrapper (pid_t pid, int signum)
70824a0dd009 provide wrapper for kill
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
47 {
21949
baeffde5c87d fix build for Windows systems
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
48 #if defined (HAVE_KILL)
21940
70824a0dd009 provide wrapper for kill
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
49 return kill (pid, signum);
21949
baeffde5c87d fix build for Windows systems
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
50 #else
baeffde5c87d fix build for Windows systems
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
51 return -1;
baeffde5c87d fix build for Windows systems
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
52 #endif
21940
70824a0dd009 provide wrapper for kill
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
53 }
70824a0dd009 provide wrapper for kill
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
54
21938
da9b960b1b2d use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents:
diff changeset
55 char *
da9b960b1b2d use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents:
diff changeset
56 octave_strsignal_wrapper (int signum)
da9b960b1b2d use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents:
diff changeset
57 {
da9b960b1b2d use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents:
diff changeset
58 return strsignal (signum);
da9b960b1b2d use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents:
diff changeset
59 }
21940
70824a0dd009 provide wrapper for kill
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
60
70824a0dd009 provide wrapper for kill
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
61 bool
70824a0dd009 provide wrapper for kill
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
62 octave_have_kill (void)
70824a0dd009 provide wrapper for kill
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
63 {
70824a0dd009 provide wrapper for kill
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
64 #if defined (HAVE_KILL)
70824a0dd009 provide wrapper for kill
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
65 return true;
70824a0dd009 provide wrapper for kill
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
66 #else
70824a0dd009 provide wrapper for kill
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
67 return false;
70824a0dd009 provide wrapper for kill
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
68 #endif
70824a0dd009 provide wrapper for kill
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
69 }
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
70
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
71 bool
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
72 octave_get_sig_number (const char *signame, int *signum)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
73 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
74 *signum = -1;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
75
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
76 // FIXME: this should probably use a perfect hash function.
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
77
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
78 if (! strcmp (signame, "SIGINT"))
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
79 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
80 #if defined (SIGINT)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
81 *signum = SIGINT;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
82 return true;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
83 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
84 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
85 else if (! strcmp (signame, "SIGBREAK"))
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
86 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
87 #if defined (SIGBREAK)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
88 *signum = SIGBREAK;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
89 return true;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
90 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
91 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
92 else if (! strcmp (signame, "SIGABRT"))
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
93 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
94 #if defined (SIGABRT)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
95 *signum = SIGABRT;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
96 return true;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
97 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
98 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
99 else if (! strcmp (signame, "SIGALRM"))
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
100 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
101 #if defined (SIGALRM)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
102 *signum = SIGALRM;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
103 return true;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
104 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
105 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
106 else if (! strcmp (signame, "SIGBUS"))
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
107 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
108 #if defined (SIGBUS)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
109 *signum = SIGBUS;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
110 return true;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
111 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
112 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
113 else if (! strcmp (signame, "SIGCHLD"))
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
114 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
115 #if defined (SIGCHLD)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
116 *signum = SIGCHLD;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
117 return true;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
118 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
119 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
120 else if (! strcmp (signame, "SIGCLD"))
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
121 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
122 #if defined (SIGCLD)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
123 *signum = SIGCLD;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
124 return true;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
125 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
126 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
127 else if (! strcmp (signame, "SIGCONT"))
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
128 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
129 #if defined (SIGCONT)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
130 *signum = SIGCONT;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
131 return true;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
132 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
133 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
134 else if (! strcmp (signame, "SIGEMT"))
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
135 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
136 #if defined (SIGEMT)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
137 *signum = SIGEMT;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
138 return true;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
139 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
140 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
141 else if (! strcmp (signame, "SIGFPE"))
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
142 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
143 #if defined (SIGFPE)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
144 *signum = SIGFPE;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
145 return true;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
146 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
147 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
148 else if (! strcmp (signame, "SIGHUP"))
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
149 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
150 #if defined (SIGHUP)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
151 *signum = SIGHUP;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
152 return true;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
153 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
154 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
155 else if (! strcmp (signame, "SIGILL"))
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
156 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
157 #if defined (SIGILL)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
158 *signum = SIGILL;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
159 return true;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
160 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
161 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
162 else if (! strcmp (signame, "SIGINFO"))
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
163 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
164 #if defined (SIGINFO)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
165 *signum = SIGINFO;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
166 return true;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
167 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
168 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
169 else if (! strcmp (signame, "SIGINT"))
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
170 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
171 #if defined (SIGINT)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
172 *signum = SIGINT;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
173 return true;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
174 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
175 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
176 else if (! strcmp (signame, "SIGIOT"))
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
177 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
178 #if defined (SIGIOT)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
179 *signum = SIGIOT;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
180 return true;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
181 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
182 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
183 else if (! strcmp (signame, "SIGLOST"))
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
184 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
185 #if defined (SIGLOST)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
186 *signum = SIGLOST;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
187 return true;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
188 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
189 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
190 else if (! strcmp (signame, "SIGPIPE"))
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
191 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
192 #if defined (SIGPIPE)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
193 *signum = SIGPIPE;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
194 return true;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
195 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
196 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
197 else if (! strcmp (signame, "SIGPOLL"))
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
198 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
199 #if defined (SIGPOLL)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
200 *signum = SIGPOLL;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
201 return true;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
202 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
203 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
204 else if (! strcmp (signame, "SIGPROF"))
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
205 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
206 #if defined (SIGPROF)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
207 *signum = SIGPROF;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
208 return true;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
209 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
210 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
211 else if (! strcmp (signame, "SIGPWR"))
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
212 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
213 #if defined (SIGPWR)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
214 *signum = SIGPWR;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
215 return true;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
216 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
217 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
218 else if (! strcmp (signame, "SIGQUIT"))
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
219 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
220 #if defined (SIGQUIT)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
221 *signum = SIGQUIT;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
222 return true;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
223 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
224 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
225 else if (! strcmp (signame, "SIGSEGV"))
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
226 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
227 #if defined (SIGSEGV)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
228 *signum = SIGSEGV;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
229 return true;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
230 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
231 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
232 else if (! strcmp (signame, "SIGSTOP"))
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
233 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
234 #if defined (SIGSTOP)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
235 *signum = SIGSTOP;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
236 return true;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
237 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
238 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
239 else if (! strcmp (signame, "SIGSYS"))
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
240 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
241 #if defined (SIGSYS)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
242 *signum = SIGSYS;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
243 return true;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
244 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
245 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
246 else if (! strcmp (signame, "SIGTERM"))
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
247 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
248 #if defined (SIGTERM)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
249 *signum = SIGTERM;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
250 return true;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
251 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
252 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
253 else if (! strcmp (signame, "SIGTRAP"))
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
254 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
255 #if defined (SIGTRAP)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
256 *signum = SIGTRAP;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
257 return true;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
258 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
259 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
260 else if (! strcmp (signame, "SIGTSTP"))
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
261 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
262 #if defined (SIGTSTP)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
263 *signum = SIGTSTP;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
264 return true;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
265 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
266 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
267 else if (! strcmp (signame, "SIGTTIN"))
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
268 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
269 #if defined (SIGTTIN)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
270 *signum = SIGTTIN;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
271 return true;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
272 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
273 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
274 else if (! strcmp (signame, "SIGTTOU"))
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
275 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
276 #if defined (SIGTTOU)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
277 *signum = SIGTTOU;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
278 return true;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
279 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
280 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
281 else if (! strcmp (signame, "SIGURG"))
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
282 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
283 #if defined (SIGURG)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
284 *signum = SIGURG;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
285 return true;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
286 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
287 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
288 else if (! strcmp (signame, "SIGUSR1"))
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
289 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
290 #if defined (SIGUSR1)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
291 *signum = SIGUSR1;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
292 return true;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
293 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
294 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
295 else if (! strcmp (signame, "SIGUSR2"))
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
296 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
297 #if defined (SIGUSR2)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
298 *signum = SIGUSR2;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
299 return true;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
300 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
301 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
302 else if (! strcmp (signame, "SIGVTALRM"))
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
303 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
304 #if defined (SIGVTALRM)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
305 *signum = SIGVTALRM;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
306 return true;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
307 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
308 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
309 else if (! strcmp (signame, "SIGIO"))
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
310 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
311 #if defined (SIGIO)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
312 *signum = SIGIO;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
313 return true;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
314 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
315 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
316 else if (! strcmp (signame, "SIGWINCH"))
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
317 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
318 #if defined (SIGWINCH)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
319 *signum = SIGWINCH;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
320 return true;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
321 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
322 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
323 else if (! strcmp (signame, "SIGXCPU"))
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
324 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
325 #if defined (SIGXCPU)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
326 *signum = SIGXCPU;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
327 return true;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
328 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
329 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
330 else if (! strcmp (signame, "SIGXFSZ"))
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
331 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
332 #if defined (SIGXFSZ)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
333 *signum = SIGXFSZ;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
334 return true;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
335 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
336 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
337
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
338 return false;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
339 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
340
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
341 octave_sig_handler *
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
342 octave_set_signal_handler_internal (int sig, octave_sig_handler *handler,
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
343 bool restart_syscalls)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
344 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
345 struct sigaction act, oact;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
346
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
347 act.sa_handler = handler;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
348 act.sa_flags = 0;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
349
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
350 #if defined (SIGALRM)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
351 if (sig == SIGALRM)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
352 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
353 # if defined (SA_INTERRUPT)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
354 act.sa_flags |= SA_INTERRUPT;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
355 # endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
356 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
357 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
358 #if defined (SA_RESTART)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
359 # if defined (SIGALRM)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
360 else
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
361 # endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
362 // FIXME: Do we also need to explicitly disable SA_RESTART?
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
363 if (restart_syscalls)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
364 act.sa_flags |= SA_RESTART;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
365 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
366
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
367 sigemptyset (&act.sa_mask);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
368 sigemptyset (&oact.sa_mask);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
369
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
370 sigaction (sig, &act, &oact);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
371
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
372 return oact.sa_handler;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
373 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
374
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
375 octave_sig_handler *
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
376 octave_set_signal_handler_by_name (const char *signame,
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
377 octave_sig_handler *handler,
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
378 bool restart_syscalls)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
379 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
380 int sig;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
381
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
382 return (octave_get_sig_number (signame, &sig)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
383 ? octave_set_signal_handler_internal (sig, handler, restart_syscalls)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
384 : 0);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
385 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
386
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
387 int
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
388 octave_num_signals (void)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
389 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
390 return NSIG;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
391 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
392
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
393 typedef struct
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
394 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
395 sigset_t nvar;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
396 sigset_t ovar;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
397 } sigset_info;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
398
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
399 void *
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
400 octave_block_child (void)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
401 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
402 #if defined (SIGCHLD)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
403
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
404 sigset_info *context = (sigset_info *) malloc (sizeof (sigset_info));
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
405
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
406 if (context)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
407 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
408 sigemptyset (&(context->nvar));
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
409 sigaddset (&(context->nvar), SIGCHLD);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
410 sigemptyset (&(context->ovar));
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
411 sigprocmask (SIG_BLOCK, &(context->nvar), &(context->ovar));
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
412 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
413
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
414 return context;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
415
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
416 #else
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
417
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
418 return 0;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
419
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
420 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
421 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
422
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
423 void
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
424 octave_unblock_child (void *context_arg)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
425 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
426 if (context_arg)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
427 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
428 sigset_info *context = (sigset_info *) context_arg;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
429
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
430 sigprocmask (SIG_SETMASK, &(context->ovar), 0);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
431
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
432 free (context);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
433 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
434 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
435
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
436 static void
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
437 block_or_unblock_signal (int how, int sig)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
438 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
439 #if ! defined (__WIN32__) || defined (__CYGWIN__)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
440 // Blocking/unblocking signals at thread level is only supported
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
441 // on platform with fully compliant POSIX threads. This is not
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
442 // supported on Win32. Moreover, we have to make sure that SIGINT
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
443 // handler is not installed before calling AllocConsole: installing
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
444 // a SIGINT handler internally calls SetConsoleCtrlHandler, which
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
445 // must be called after AllocConsole to be effective.
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
446
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
447 sigset_t signal_mask;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
448
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
449 sigemptyset (&signal_mask);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
450
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
451 sigaddset (&signal_mask, sig);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
452
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
453 pthread_sigmask (how, &signal_mask, 0);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
454 #endif
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
455 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
456
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
457 void
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
458 octave_block_interrupt_signal (void)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
459 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
460 block_or_unblock_signal (SIG_BLOCK, SIGINT);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
461 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
462
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
463 void
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
464 octave_unblock_interrupt_signal (void)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
465 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
466 block_or_unblock_signal (SIG_UNBLOCK, SIGINT);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
467 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
468
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
469
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
470 /* Allow us to save the signal mask and then restore it to the most
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
471 recently saved value. This is necessary when using the POSIX signal
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
472 handling interface on some systems calling longjmp out of the signal
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
473 handler to get to the top level on an interrupt doesn't restore the
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
474 original signal mask. Alternatively, we could use
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
475 sigsetjmp/siglongjmp, but saving and restoring the signal mask
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
476 ourselves works ok and seems simpler just now. */
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
477
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
478 static sigset_t octave_signal_mask;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
479
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
480 void
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
481 octave_save_signal_mask (void)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
482 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
483 sigprocmask (0, 0, &octave_signal_mask);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
484 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
485
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
486 void
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
487 octave_restore_signal_mask (void)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
488 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
489 sigprocmask (SIG_SETMASK, &octave_signal_mask, 0);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
490 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
491
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
492 int
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
493 octave_raise_wrapper (int signum)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
494 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
495 return raise (signum);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21940
diff changeset
496 }