1124208Sdes/* $Id: bsd-waitpid.h,v 1.5 2003/08/29 16:59:52 mouring Exp $ */ 2124208Sdes 398937Sdes/* 4124208Sdes * Copyright (c) 2000 Ben Lindstrom. All rights reserved. 5124208Sdes * 698937Sdes * Redistribution and use in source and binary forms, with or without 798937Sdes * modification, are permitted provided that the following conditions 898937Sdes * are met: 998937Sdes * 1. Redistributions of source code must retain the above copyright 1098937Sdes * notice, this list of conditions and the following disclaimer. 1198937Sdes * 2. Redistributions in binary form must reproduce the above copyright 1298937Sdes * notice, this list of conditions and the following disclaimer in the 1398937Sdes * documentation and/or other materials provided with the distribution. 1498937Sdes * 1598937Sdes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1698937Sdes * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1798937Sdes * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1898937Sdes * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 1998937Sdes * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2098937Sdes * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2198937Sdes * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2298937Sdes * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2398937Sdes * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2498937Sdes * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2598937Sdes * 2698937Sdes */ 2798937Sdes 2898937Sdes#ifndef _BSD_WAITPID_H 2998937Sdes#define _BSD_WAITPID_H 3098937Sdes 3198937Sdes#ifndef HAVE_WAITPID 3298937Sdes/* Clean out any potental issues */ 3398937Sdes#undef WIFEXITED 3498937Sdes#undef WIFSTOPPED 3598937Sdes#undef WIFSIGNALED 3698937Sdes 3798937Sdes/* Define required functions to mimic a POSIX look and feel */ 3898937Sdes#define _W_INT(w) (*(int*)&(w)) /* convert union wait to int */ 3998937Sdes#define WIFEXITED(w) (!((_W_INT(w)) & 0377)) 4098937Sdes#define WIFSTOPPED(w) ((_W_INT(w)) & 0100) 4198937Sdes#define WIFSIGNALED(w) (!WIFEXITED(w) && !WIFSTOPPED(w)) 4298937Sdes#define WEXITSTATUS(w) (int)(WIFEXITED(w) ? ((_W_INT(w) >> 8) & 0377) : -1) 4398937Sdes#define WTERMSIG(w) (int)(WIFSIGNALED(w) ? (_W_INT(w) & 0177) : -1) 4498937Sdes#define WCOREFLAG 0x80 4598937Sdes#define WCOREDUMP(w) ((_W_INT(w)) & WCOREFLAG) 4698937Sdes 4798937Sdes/* Prototype */ 48124208Sdespid_t waitpid(int, int *, int); 4998937Sdes 5098937Sdes#endif /* !HAVE_WAITPID */ 5198937Sdes#endif /* _BSD_WAITPID_H */ 52