GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
wait-wrappers.c
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2016-2018 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software: you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <https://www.gnu.org/licenses/>.
20 
21 */
22 
23 // These functions may be provided by gnulib. We don't include gnulib
24 // headers directly in Octave's C++ source files to avoid problems that
25 // may be caused by the way that gnulib overrides standard library
26 // functions.
27 
28 #if defined (HAVE_CONFIG_H)
29 # include "config.h"
30 #endif
31 
32 #include <sys/types.h>
33 #include <sys/wait.h>
34 
35 #include "wait-wrappers.h"
36 
37 #if ! defined (WCONTINUE)
38 # define WCONTINUE 0
39 #endif
40 
41 #if ! defined (WNOHANG)
42 # define WNOHANG 0
43 #endif
44 
45 #if ! defined (WUNTRACED)
46 # define WUNTRACED 0
47 #endif
48 
49 #if ! defined (WIFCONTINUED)
50 # define WIFCONTINUED(x) false
51 #endif
52 
53 pid_t
54 octave_waitpid_wrapper (pid_t pid, int *statusp, int options)
55 {
56 #if defined (__WIN32__) && ! defined (__CYGWIN__)
57 
58  octave_unused_parameter (pid);
59  octave_unused_parameter (options);
60 
61  // gnulib's waitpid replacement currently uses _cwait, which
62  // apparently only works with console applications.
63  *statusp = 0;
64  return -1;
65 #else
66  return waitpid (pid, statusp, options);
67 #endif
68 }
69 
70 int
72 {
73  return WCONTINUE;
74 }
75 
76 int
78 {
79  return WNOHANG;
80 }
81 
82 int
84 {
85  return WUNTRACED;
86 }
87 
88 #if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC)
89 // Disable the unused parameter warning for the following wrapper functions.
90 // The <sys/wait.h> header provided by gnulib may define some of the W*
91 // macros to expand to a constant and ignore the parameter.
92 #pragma GCC diagnostic push
93 #pragma GCC diagnostic ignored "-Wunused-parameter"
94 #endif
95 
96 int
98 {
99  return WCOREDUMP (status);
100 }
101 
102 int
104 {
105  return WEXITSTATUS (status);
106 }
107 
108 bool
110 {
111  return WIFCONTINUED (status);
112 }
113 
114 bool
116 {
117  return WIFEXITED (status);
118 }
119 
120 bool
122 {
123  return WIFSIGNALED (status);
124 }
125 
126 bool
128 {
129  return WIFSTOPPED (status);
130 }
131 
132 int
134 {
135  return WSTOPSIG (status);
136 }
137 
138 int
140 {
141  return WTERMSIG (status);
142 }
143 
144 #if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC)
145 // Restore prevailing warning state for remainder of the file.
146 #pragma GCC diagnostic pop
147 #endif
bool octave_wifsignaled_wrapper(int status)
bool octave_wifexited_wrapper(int status)
waitpid(pid)
int octave_wcontinue_wrapper(void)
Definition: wait-wrappers.c:71
#define WNOHANG
Definition: wait-wrappers.c:42
bool octave_wifcontinued_wrapper(int status)
int octave_wtermsig_wrapper(int status)
int octave_wstopsig_wrapper(int status)
int octave_wexitstatus_wrapper(int status)
OCTAVE_EXPORT octave_value_list only variables visible in the local scope are displayed The following are valid options
Definition: variables.cc:1862
pid_t octave_waitpid_wrapper(pid_t pid, int *statusp, int options)
Definition: wait-wrappers.c:54
#define WCONTINUE
Definition: wait-wrappers.c:38
int octave_wcoredump_wrapper(int status)
Definition: wait-wrappers.c:97
#define WIFCONTINUED(x)
Definition: wait-wrappers.c:50
#define WUNTRACED
Definition: wait-wrappers.c:46
int octave_wuntraced_wrapper(void)
Definition: wait-wrappers.c:83
int octave_wnohang_wrapper(void)
Definition: wait-wrappers.c:77
bool octave_wifstopped_wrapper(int status)