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 #include <sys/types.h> |
|
33 |
|
34 #if defined (NeXT) && ! defined (_POSIX_SOURCE) |
|
35 #define HAVE_SYS_WAIT_H |
|
36 #endif |
|
37 |
|
38 #if defined HAVE_SYS_WAIT_H |
|
39 #include <sys/wait.h> |
|
40 #endif |
|
41 |
|
42 #if defined (NeXT) |
|
43 #define HAVE_WAITPID 1 |
5453
|
44 #define WAITPID(a, b, c) \ |
2935
|
45 wait4 ((a) == -1 ? 0 : (a), (union wait *)(b), c, 0) |
|
46 |
5453
|
47 /* Use the defaults below. */ |
2935
|
48 #undef WIFEXITED |
|
49 #undef WEXITSTATUS |
|
50 #undef WIFSIGNALLED |
|
51 #endif |
|
52 |
5453
|
53 /* NeXT has sys/wait.h, but it is not compatible with POSIX.1, so we |
|
54 try to define waitpid in terms of wait4. */ |
2935
|
55 |
|
56 #if defined (NeXT) |
|
57 #include <sys/wait.h> |
|
58 #define waitpid(a, b, c) \ |
|
59 wait4 ((a) == -1 ? 0 : (a), (union wait *)(b), c, 0) |
|
60 #endif |
|
61 |
|
62 #ifndef WIFEXITED |
|
63 #define WIFEXITED(stat_val) (((stat_val) & 255) == 0) |
|
64 #endif |
|
65 |
|
66 #ifndef WEXITSTATUS |
|
67 #define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) |
|
68 #endif |
|
69 |
|
70 #ifndef WIFSIGNALLED |
|
71 #define WIFSIGNALLED(stat_val) \ |
|
72 (((stat_val) & 0177) != 0177 && ((stat_val) & 0177) != 0) |
|
73 #endif |
|
74 |
6096
|
75 #if defined (__MINGW32__) || defined (_MSC_VER) |
5453
|
76 #define HAVE_WAITPID 1 |
|
77 #include <process.h> |
|
78 #define WAITPID(a, b, c) _cwait (b, a, c) |
|
79 /* Action argument is ignored for _cwait, so arbitrary definition. */ |
|
80 #define WNOHANG 0 |
|
81 #else |
|
82 #define WAITPID(a, b, c) waitpid (a, b, c) |
|
83 #endif |
|
84 |
|
85 #ifdef __cplusplus |
|
86 } |
|
87 #endif |
|
88 |
2935
|
89 #endif |