From: Ulrich Drepper Date: Tue, 21 Mar 2000 01:23:06 +0000 (+0000) Subject: AIX implementation of waitid. X-Git-Tag: upstream/2.30~10627^2~2559 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3d0f99ef86517ddba0e011412edd78bbf89148f5;p=external%2Fglibc.git AIX implementation of waitid. --- diff --git a/sysdeps/unix/sysv/aix/waitid.c b/sysdeps/unix/sysv/aix/waitid.c new file mode 100644 index 0000000..a1fcae0 --- /dev/null +++ b/sysdeps/unix/sysv/aix/waitid.c @@ -0,0 +1,82 @@ +/* Pseudo implementation of waitid. + Copyright (C) 1997, 1998, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Zack Weinberg , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#define __need_NULL +#include +#include +#include + +#include + +extern pid_t kwaitpid (int *stat_loc, pid_t pid, int options, + struct rusage *ru_loc, siginfo_t *infop); + +int +waitid (idtype, id, infop, options) + idtype_t idtype; + id_t id; + siginfo_t *infop; + int options; +{ + pid_t pid, child; + int status; + + switch (idtype) + { + case P_PID: + if(id <= 0) + goto invalid; + pid = (pid_t) id; + break; + case P_PGID: + if (id < 0 || id == 1) + goto invalid; + pid = (pid_t) -id; + break; + case P_ALL: + pid = -1; + break; + default: + invalid: + __set_errno (EINVAL); + return -1; + } + + /* Technically we're supposed to return EFAULT if infop is bogus, + but that would involve mucking with signals, which is + too much hassle. User will have to deal with SIGSEGV/SIGBUS. + We just check for a null pointer. */ + + if (infop == NULL) + { + __set_errno (EFAULT); + return -1; + } + + child = kwaitpid (&status, pid, options, NULL, infop); + + if (child == -1) + /* `waitpid' set `errno' for us. */ + return -1; + + return 0; +}