bsd-waitpid.c revision 98937
195967Speter/* 295967Speter * Redistribution and use in source and binary forms, with or without 395967Speter * modification, are permitted provided that the following conditions 495967Speter * are met: 595967Speter * 1. Redistributions of source code must retain the above copyright 695967Speter * notice, this list of conditions and the following disclaimer. 795967Speter * 2. Redistributions in binary form must reproduce the above copyright 895967Speter * notice, this list of conditions and the following disclaimer in the 995967Speter * documentation and/or other materials provided with the distribution. 1095967Speter * 1195967Speter * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1295967Speter * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1395967Speter * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1495967Speter * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 1595967Speter * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 1695967Speter * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 1795967Speter * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 1895967Speter * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 1995967Speter * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2095967Speter * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2195967Speter */ 2295967Speter 2395967Speter#include "includes.h" 2495967Speter 2595967SpeterRCSID("$Id: bsd-waitpid.c,v 1.3 2001/03/26 05:35:34 mouring Exp $"); 2695967Speter 2795967Speter#ifndef HAVE_WAITPID 2895967Speter#include <errno.h> 2995967Speter#include <sys/wait.h> 3095967Speter#include "bsd-waitpid.h" 3195967Speter 3295967Speterpid_t 3395967Speterwaitpid(int pid, int *stat_loc, int options) 3495967Speter{ 3595967Speter union wait statusp; 3695967Speter pid_t wait_pid; 3795967Speter 3895967Speter if (pid <= 0) { 3995967Speter if (pid != -1) { 4095967Speter errno = EINVAL; 4195967Speter return -1; 4295967Speter } 4395967Speter pid = 0; /* wait4() wants pid=0 for indiscriminate wait. */ 4495967Speter } 4595967Speter wait_pid = wait4(pid, &statusp, options, NULL); 4695967Speter if (stat_loc) 4795967Speter *stat_loc = (int) statusp.w_status; 4895967Speter 4995967Speter return wait_pid; 5095967Speter} 5195967Speter 5295967Speter#endif /* !HAVE_WAITPID */ 5395967Speter