2935
|
1 /* |
|
2 |
7017
|
3 Copyright (C) 1996, 1997, 2005, 2006, 2007 John W. Eaton |
2935
|
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 the |
7016
|
9 Free Software Foundation; either version 3 of the License, or (at your |
|
10 option) any later version. |
2935
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
7016
|
18 along with Octave; see the file COPYING. If not, see |
|
19 <http://www.gnu.org/licenses/>. |
2935
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (octave_syswait_h) |
|
24 #define octave_syswait_h 1 |
|
25 |
5453
|
26 #ifdef __cplusplus |
|
27 extern "C" { |
|
28 #endif |
|
29 |
|
30 /* This mess suggested by the autoconf manual. */ |
2935
|
31 |
|
32 #ifdef HAVE_SYS_TYPES_H |
|
33 #include <sys/types.h> |
|
34 #endif |
|
35 |
|
36 #if defined (NeXT) && ! defined (_POSIX_SOURCE) |
|
37 #define HAVE_SYS_WAIT_H |
|
38 #endif |
|
39 |
|
40 #if defined HAVE_SYS_WAIT_H |
|
41 #include <sys/wait.h> |
|
42 #endif |
|
43 |
|
44 #if defined (NeXT) |
|
45 #define HAVE_WAITPID 1 |
5453
|
46 #define WAITPID(a, b, c) \ |
2935
|
47 wait4 ((a) == -1 ? 0 : (a), (union wait *)(b), c, 0) |
|
48 |
5453
|
49 /* Use the defaults below. */ |
2935
|
50 #undef WIFEXITED |
|
51 #undef WEXITSTATUS |
|
52 #undef WIFSIGNALLED |
|
53 #endif |
|
54 |
5453
|
55 /* NeXT has sys/wait.h, but it is not compatible with POSIX.1, so we |
|
56 try to define waitpid in terms of wait4. */ |
2935
|
57 |
|
58 #if defined (NeXT) |
|
59 #include <sys/wait.h> |
|
60 #define waitpid(a, b, c) \ |
|
61 wait4 ((a) == -1 ? 0 : (a), (union wait *)(b), c, 0) |
|
62 #endif |
|
63 |
|
64 #ifndef WIFEXITED |
|
65 #define WIFEXITED(stat_val) (((stat_val) & 255) == 0) |
|
66 #endif |
|
67 |
|
68 #ifndef WEXITSTATUS |
|
69 #define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) |
|
70 #endif |
|
71 |
|
72 #ifndef WIFSIGNALLED |
|
73 #define WIFSIGNALLED(stat_val) \ |
|
74 (((stat_val) & 0177) != 0177 && ((stat_val) & 0177) != 0) |
|
75 #endif |
|
76 |
6096
|
77 #if defined (__MINGW32__) || defined (_MSC_VER) |
5453
|
78 #define HAVE_WAITPID 1 |
|
79 #include <process.h> |
|
80 #define WAITPID(a, b, c) _cwait (b, a, c) |
|
81 /* Action argument is ignored for _cwait, so arbitrary definition. */ |
|
82 #define WNOHANG 0 |
|
83 #else |
|
84 #define WAITPID(a, b, c) waitpid (a, b, c) |
|
85 #endif |
|
86 |
|
87 #ifdef __cplusplus |
|
88 } |
|
89 #endif |
|
90 |
2935
|
91 #endif |
|
92 |
|
93 /* |
|
94 ;;; Local Variables: *** |
|
95 ;;; mode: C++ *** |
|
96 ;;; End: *** |
|
97 */ |