]>
git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/gdb_wait.h
1 /* Standard wait macros.
2 Copyright (C) 2000, 2007 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA. */
24 #ifdef HAVE_SYS_WAIT_H
25 #include <sys/wait.h> /* POSIX */
28 #include <wait.h> /* legacy */
32 /* Define how to access the int that the wait system call stores.
33 This has been compatible in all Unix systems since time immemorial,
34 but various well-meaning people have defined various different
35 words for the same old bits in the same old int (sometimes claimed
36 to be a struct). We just know it's an int and we use these macros
37 to access the bits. */
39 /* The following macros are defined equivalently to their definitions
40 in POSIX.1. We fail to define WNOHANG and WUNTRACED, which POSIX.1
41 <sys/wait.h> defines, since our code does not use waitpid() (but
42 NOTE exception for GNU/Linux below). We also fail to declare
43 wait() and waitpid(). */
46 #define WIFEXITED(w) (((w)&0377) == 0)
50 #define WIFSIGNALED(w) (((w)&0377) != 0177 && ((w)&~0377) == 0)
56 /* Unfortunately, the above comment (about being compatible in all Unix
57 systems) is not quite correct for AIX, sigh. And AIX 3.2 can generate
58 status words like 0x57c (sigtrap received after load), and gdb would
61 #define WIFSTOPPED(w) ((w)&0x40)
64 #define WIFSTOPPED(w) (((w)&0377) == 0177)
69 #define WEXITSTATUS(w) (((w) >> 8) & 0377) /* same as WRETCODE */
73 #define WTERMSIG(w) ((w) & 0177)
77 #define WSTOPSIG WEXITSTATUS
80 /* These are not defined in POSIX, but are used by our programs. */
85 #define WCOREDUMP(w) (((w)&0200) != 0)
90 #define WSETEXIT(w,status) ((w) = W_EXITCODE(status,0))
92 #define WSETEXIT(w,status) ((w) = (0 | ((status) << 8)))
98 #define WSETSTOP(w,sig) ((w) = W_STOPCODE(sig))
100 #define WSETSTOP(w,sig) ((w) = (0177 | ((sig) << 8)))
104 /* For native GNU/Linux we may use waitpid and the __WCLONE option.
105 <GRIPE> It is of course dangerous not to use the REAL header file...
108 /* Bits in the third argument to `waitpid'. */
110 #define WNOHANG 1 /* Don't block waiting. */
114 #define WUNTRACED 2 /* Report status of stopped children. */
118 #define __WCLONE 0x80000000 /* Wait for cloned process. */