198944Sobrien/* Standard wait macros. 298944Sobrien Copyright 2000 Free Software Foundation, Inc. 398944Sobrien 498944Sobrien This file is part of GDB. 598944Sobrien 698944Sobrien This program is free software; you can redistribute it and/or modify 798944Sobrien it under the terms of the GNU General Public License as published by 898944Sobrien the Free Software Foundation; either version 2 of the License, or 998944Sobrien (at your option) any later version. 1098944Sobrien 1198944Sobrien This program is distributed in the hope that it will be useful, 1298944Sobrien but WITHOUT ANY WARRANTY; without even the implied warranty of 1398944Sobrien MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1498944Sobrien GNU General Public License for more details. 1598944Sobrien 1698944Sobrien You should have received a copy of the GNU General Public License 1798944Sobrien along with this program; if not, write to the Free Software 1898944Sobrien Foundation, Inc., 59 Temple Place - Suite 330, 1998944Sobrien Boston, MA 02111-1307, USA. */ 2098944Sobrien 2198944Sobrien#ifndef GDB_WAIT_H 2298944Sobrien#define GDB_WAIT_H 2398944Sobrien 2498944Sobrien#ifdef HAVE_SYS_WAIT_H 2598944Sobrien#include <sys/wait.h> /* POSIX */ 2698944Sobrien#else 2798944Sobrien#ifdef HAVE_WAIT_H 2898944Sobrien#include <wait.h> /* legacy */ 2998944Sobrien#endif 3098944Sobrien#endif 3198944Sobrien 3298944Sobrien/* Define how to access the int that the wait system call stores. 3398944Sobrien This has been compatible in all Unix systems since time immemorial, 3498944Sobrien but various well-meaning people have defined various different 3598944Sobrien words for the same old bits in the same old int (sometimes claimed 3698944Sobrien to be a struct). We just know it's an int and we use these macros 3798944Sobrien to access the bits. */ 3898944Sobrien 3998944Sobrien/* The following macros are defined equivalently to their definitions 4098944Sobrien in POSIX.1. We fail to define WNOHANG and WUNTRACED, which POSIX.1 4198944Sobrien <sys/wait.h> defines, since our code does not use waitpid() (but 4298944Sobrien NOTE exception for GNU/Linux below). We also fail to declare 4398944Sobrien wait() and waitpid(). */ 4498944Sobrien 4598944Sobrien#ifndef WIFEXITED 4698944Sobrien#define WIFEXITED(w) (((w)&0377) == 0) 4798944Sobrien#endif 4898944Sobrien 4998944Sobrien#ifndef WIFSIGNALED 5098944Sobrien#define WIFSIGNALED(w) (((w)&0377) != 0177 && ((w)&~0377) == 0) 5198944Sobrien#endif 5298944Sobrien 5398944Sobrien#ifndef WIFSTOPPED 5498944Sobrien#ifdef IBM6000 5598944Sobrien 5698944Sobrien/* Unfortunately, the above comment (about being compatible in all Unix 5798944Sobrien systems) is not quite correct for AIX, sigh. And AIX 3.2 can generate 5898944Sobrien status words like 0x57c (sigtrap received after load), and gdb would 5998944Sobrien choke on it. */ 6098944Sobrien 6198944Sobrien#define WIFSTOPPED(w) ((w)&0x40) 6298944Sobrien 6398944Sobrien#else 6498944Sobrien#define WIFSTOPPED(w) (((w)&0377) == 0177) 6598944Sobrien#endif 6698944Sobrien#endif 6798944Sobrien 6898944Sobrien#ifndef WEXITSTATUS 6998944Sobrien#define WEXITSTATUS(w) (((w) >> 8) & 0377) /* same as WRETCODE */ 7098944Sobrien#endif 7198944Sobrien 7298944Sobrien#ifndef WTERMSIG 7398944Sobrien#define WTERMSIG(w) ((w) & 0177) 7498944Sobrien#endif 7598944Sobrien 7698944Sobrien#ifndef WSTOPSIG 7798944Sobrien#define WSTOPSIG WEXITSTATUS 7898944Sobrien#endif 7998944Sobrien 8098944Sobrien/* These are not defined in POSIX, but are used by our programs. */ 8198944Sobrien 8298944Sobrien#define WAITTYPE int 8398944Sobrien 8498944Sobrien#ifndef WCOREDUMP 8598944Sobrien#define WCOREDUMP(w) (((w)&0200) != 0) 8698944Sobrien#endif 8798944Sobrien 8898944Sobrien#ifndef WSETEXIT 8998944Sobrien# ifdef W_EXITCODE 9098944Sobrien#define WSETEXIT(w,status) ((w) = W_EXITCODE(status,0)) 9198944Sobrien# else 9298944Sobrien#define WSETEXIT(w,status) ((w) = (0 | ((status) << 8))) 9398944Sobrien# endif 9498944Sobrien#endif 9598944Sobrien 9698944Sobrien#ifndef WSETSTOP 9798944Sobrien# ifdef W_STOPCODE 9898944Sobrien#define WSETSTOP(w,sig) ((w) = W_STOPCODE(sig)) 9998944Sobrien# else 10098944Sobrien#define WSETSTOP(w,sig) ((w) = (0177 | ((sig) << 8))) 10198944Sobrien# endif 10298944Sobrien#endif 10398944Sobrien 10498944Sobrien/* For native GNU/Linux we may use waitpid and the __WCLONE option. 10598944Sobrien <GRIPE> It is of course dangerous not to use the REAL header file... 10698944Sobrien </GRIPE>. */ 10798944Sobrien 10898944Sobrien/* Bits in the third argument to `waitpid'. */ 10998944Sobrien#ifndef WNOHANG 11098944Sobrien#define WNOHANG 1 /* Don't block waiting. */ 11198944Sobrien#endif 11298944Sobrien 11398944Sobrien#ifndef WUNTRACED 11498944Sobrien#define WUNTRACED 2 /* Report status of stopped children. */ 11598944Sobrien#endif 11698944Sobrien 11798944Sobrien#ifndef __WCLONE 11898944Sobrien#define __WCLONE 0x80000000 /* Wait for cloned process. */ 11998944Sobrien#endif 12098944Sobrien 12198944Sobrien#endif 122