Browse Source

A little update to wait* and a minor syscall cleanup.

Eric Andersen 23 years ago
parent
commit
b8e0118b10

+ 4 - 4
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

+ 2 - 12
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

+ 6 - 2
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);
 }
+
+

+ 8 - 2
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);
 }

+ 9 - 0
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);
+}