diff options
author | Eric Andersen <andersen@codepoet.org> | 2001-01-16 19:14:23 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2001-01-16 19:14:23 +0000 |
commit | b8e0118b10424c890598953f877a53a44ff6f9d7 (patch) | |
tree | 81a354934cc788b459d22b809d32586abe62021c /libc | |
parent | 31e36a1498a8edcc3db48dc4c5a5f8e7cae276ec (diff) |
A little update to wait* and a minor syscall cleanup.
Diffstat (limited to 'libc')
-rw-r--r-- | libc/sysdeps/linux/common/Makefile | 8 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/syscalls.c | 14 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/wait.c | 8 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/wait3.c | 10 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/waitpid.c | 9 |
5 files changed, 29 insertions, 20 deletions
diff --git a/libc/sysdeps/linux/common/Makefile b/libc/sysdeps/linux/common/Makefile index 46fd22008..0d066bc8c 100644 --- a/libc/sysdeps/linux/common/Makefile +++ b/libc/sysdeps/linux/common/Makefile @@ -25,10 +25,10 @@ TOPDIR=../../../ include $(TOPDIR)Rules.mak LIBC=$(TOPDIR)libc.a -CSRC =closedir.c dirfd.c getdents.c getdnnm.c gethstnm.c getpagesize.c \ - isatty.c kernel_version.c mkfifo.c opendir.c readdir.c rewinddir.c \ - seekdir.c setegid.c seteuid.c setpgrp.c statfix.c tell.c telldir.c \ - wait.c wait3.c _xmknod.c libc_init.c errno.c +CSRC= _xmknod.c waitpid.c getdents.c kernel_version.c rewinddir.c statfix.c \ + getdnnm.c libc_init.c seekdir.c telldir.c tell.c gethstnm.c mkfifo.c \ + setegid.c wait.c errno.c closedir.c getpagesize.c opendir.c seteuid.c \ + wait3.c dirfd.c isatty.c readdir.c setpgrp.c COBJS=$(patsubst %.c,%.o, $(CSRC)) NISRC= _fxstat.c _lxstat.c _xstat.c diff --git a/libc/sysdeps/linux/common/syscalls.c b/libc/sysdeps/linux/common/syscalls.c index 6a8f73eb9..931958de5 100644 --- a/libc/sysdeps/linux/common/syscalls.c +++ b/libc/sysdeps/linux/common/syscalls.c @@ -86,10 +86,7 @@ _syscall1(int, close, int, fd); #endif //#define __NR_waitpid 7 -#include <sys/wait.h> -#ifdef L_waitpid -_syscall3(pid_t, waitpid, pid_t, pid, int *, status, int, options); -#endif +// Implemented using wait4 //#define __NR_creat 8 #ifdef L_creat @@ -792,9 +789,7 @@ _syscall0(int, vhangup); //#define __NR_wait4 114 #ifdef L_wait4 -#include <sys/wait.h> -_syscall4(pid_t, wait4, pid_t, pid, int *, status, int, options, - struct rusage *, rusage); +_syscall4(int, wait4, pid_t, pid, int *, status, int, opts, void *, rusage); #endif //#define __NR_swapoff 115 @@ -966,12 +961,7 @@ _syscall1(pid_t, getsid, pid_t, pid); #endif //#define __NR_fdatasync 148 -// //#define __NR__sysctl 149 -//#ifdef L_sysctl -//_syscall1(int, sysctl, struct __sysctl_args *, args); -//#endif - //#define __NR_mlock 150 //#define __NR_munlock 151 //#define __NR_mlockall 152 diff --git a/libc/sysdeps/linux/common/wait.c b/libc/sysdeps/linux/common/wait.c index dc9898617..6520013f0 100644 --- a/libc/sysdeps/linux/common/wait.c +++ b/libc/sysdeps/linux/common/wait.c @@ -3,7 +3,11 @@ #include <sys/wait.h> #include <sys/resource.h> -__pid_t wait(__WAIT_STATUS wait_stat) +/* Wait for a child to die. When one does, put its status in *STAT_LOC + * and return its process ID. For errors, return (pid_t) -1. */ +__pid_t wait (__WAIT_STATUS_DEFN stat_loc) { - return wait4((-1) /* WAIT_ANY */, wait_stat, 0, NULL); + return wait4 (WAIT_ANY, stat_loc, 0, (struct rusage *) NULL); } + + diff --git a/libc/sysdeps/linux/common/wait3.c b/libc/sysdeps/linux/common/wait3.c index 7448b6294..6a8bc77fc 100644 --- a/libc/sysdeps/linux/common/wait3.c +++ b/libc/sysdeps/linux/common/wait3.c @@ -3,7 +3,13 @@ #include <sys/wait.h> #include <sys/resource.h> -__pid_t wait3(__WAIT_STATUS wait_stat, int options, struct rusage *reserved) + +/* Wait for a child to exit. When one does, put its status in *STAT_LOC and + * return its process ID. For errors return (pid_t) -1. If USAGE is not nil, + * store information about the child's resource usage (as a `struct rusage') + * there. If the WUNTRACED bit is set in OPTIONS, return status for stopped + * children; otherwise don't. */ +pid_t wait3 (__WAIT_STATUS stat_loc, int options, struct rusage * usage) { - return wait4((-1) /* WAIT_ANY*/, wait_stat, options, reserved); + return wait4 (WAIT_ANY, stat_loc, options, usage); } diff --git a/libc/sysdeps/linux/common/waitpid.c b/libc/sysdeps/linux/common/waitpid.c new file mode 100644 index 000000000..255a3c84e --- /dev/null +++ b/libc/sysdeps/linux/common/waitpid.c @@ -0,0 +1,9 @@ +#include <syscall.h> +#include <sys/types.h> +#include <sys/wait.h> +#include <sys/resource.h> + +__pid_t waitpid(__pid_t pid, int *wait_stat, int options) +{ + return wait4(pid, wait_stat, options, NULL); +} |