1d95e11bfSDag-Erling Smørgrav /* $Id: bsd-waitpid.h,v 1.5 2003/08/29 16:59:52 mouring Exp $ */ 2d95e11bfSDag-Erling Smørgrav 383d2307dSDag-Erling Smørgrav /* 4d95e11bfSDag-Erling Smørgrav * Copyright (c) 2000 Ben Lindstrom. All rights reserved. 5d95e11bfSDag-Erling Smørgrav * 683d2307dSDag-Erling Smørgrav * Redistribution and use in source and binary forms, with or without 783d2307dSDag-Erling Smørgrav * modification, are permitted provided that the following conditions 883d2307dSDag-Erling Smørgrav * are met: 983d2307dSDag-Erling Smørgrav * 1. Redistributions of source code must retain the above copyright 1083d2307dSDag-Erling Smørgrav * notice, this list of conditions and the following disclaimer. 1183d2307dSDag-Erling Smørgrav * 2. Redistributions in binary form must reproduce the above copyright 1283d2307dSDag-Erling Smørgrav * notice, this list of conditions and the following disclaimer in the 1383d2307dSDag-Erling Smørgrav * documentation and/or other materials provided with the distribution. 1483d2307dSDag-Erling Smørgrav * 1583d2307dSDag-Erling Smørgrav * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1683d2307dSDag-Erling Smørgrav * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1783d2307dSDag-Erling Smørgrav * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1883d2307dSDag-Erling Smørgrav * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 1983d2307dSDag-Erling Smørgrav * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2083d2307dSDag-Erling Smørgrav * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2183d2307dSDag-Erling Smørgrav * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2283d2307dSDag-Erling Smørgrav * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2383d2307dSDag-Erling Smørgrav * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2483d2307dSDag-Erling Smørgrav * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2583d2307dSDag-Erling Smørgrav * 2683d2307dSDag-Erling Smørgrav */ 2783d2307dSDag-Erling Smørgrav 2883d2307dSDag-Erling Smørgrav #ifndef _BSD_WAITPID_H 2983d2307dSDag-Erling Smørgrav #define _BSD_WAITPID_H 3083d2307dSDag-Erling Smørgrav 3183d2307dSDag-Erling Smørgrav #ifndef HAVE_WAITPID 3283d2307dSDag-Erling Smørgrav /* Clean out any potental issues */ 3383d2307dSDag-Erling Smørgrav #undef WIFEXITED 3483d2307dSDag-Erling Smørgrav #undef WIFSTOPPED 3583d2307dSDag-Erling Smørgrav #undef WIFSIGNALED 3683d2307dSDag-Erling Smørgrav 3783d2307dSDag-Erling Smørgrav /* Define required functions to mimic a POSIX look and feel */ 3883d2307dSDag-Erling Smørgrav #define _W_INT(w) (*(int*)&(w)) /* convert union wait to int */ 3983d2307dSDag-Erling Smørgrav #define WIFEXITED(w) (!((_W_INT(w)) & 0377)) 4083d2307dSDag-Erling Smørgrav #define WIFSTOPPED(w) ((_W_INT(w)) & 0100) 4183d2307dSDag-Erling Smørgrav #define WIFSIGNALED(w) (!WIFEXITED(w) && !WIFSTOPPED(w)) 4283d2307dSDag-Erling Smørgrav #define WEXITSTATUS(w) (int)(WIFEXITED(w) ? ((_W_INT(w) >> 8) & 0377) : -1) 4383d2307dSDag-Erling Smørgrav #define WTERMSIG(w) (int)(WIFSIGNALED(w) ? (_W_INT(w) & 0177) : -1) 4483d2307dSDag-Erling Smørgrav #define WCOREFLAG 0x80 4583d2307dSDag-Erling Smørgrav #define WCOREDUMP(w) ((_W_INT(w)) & WCOREFLAG) 4683d2307dSDag-Erling Smørgrav 4783d2307dSDag-Erling Smørgrav /* Prototype */ 48d95e11bfSDag-Erling Smørgrav pid_t waitpid(int, int *, int); 4983d2307dSDag-Erling Smørgrav 5083d2307dSDag-Erling Smørgrav #endif /* !HAVE_WAITPID */ 5183d2307dSDag-Erling Smørgrav #endif /* _BSD_WAITPID_H */ 52