ref: c09d58a66ff792a639ec64e51f658ef3277a7441
parent: c56ea52bd1002ff2b1cb6b69c298dddf2292ee87
author: Roberto E. Vargas Caballero <[email protected]>
date: Tue May 17 18:09:09 EDT 2022
libc: Add _waitpid() syscall _waitpid() is implemented in bsd and linux systems using _wait4() syscall.
--- a/include/bits/darwin/sys.h
+++ b/include/bits/darwin/sys.h
@@ -27,3 +27,4 @@
extern int _kill(pid_t, int);
extern int _sigaction(int, struct sigaction *, struct sigaction *);
extern pid_t _wait4(pid_t, int *, int, struct rusage *);
+extern pid_t _waitpid(pid_t, int *, int);
--- a/include/bits/dragonfly/sys.h
+++ b/include/bits/dragonfly/sys.h
@@ -27,3 +27,4 @@
extern int _kill(pid_t, int);
extern int _sigaction(int, struct sigaction *, struct sigaction *);
extern pid_t _wait4(pid_t, int *, int, struct rusage *);
+extern pid_t _waitpid(pid_t, int *, int);
--- a/include/bits/linux/sys.h
+++ b/include/bits/linux/sys.h
@@ -27,3 +27,4 @@
extern int _kill(pid_t, int);
extern int _sigaction(int, struct sigaction *, struct sigaction *);
extern pid_t _wait4(pid_t, int *, int, struct rusage *);
+extern pid_t _waitpid(pid_t, int *, int);
--- a/include/bits/netbsd/sys.h
+++ b/include/bits/netbsd/sys.h
@@ -27,3 +27,4 @@
extern int _kill(pid_t, int);
extern int _sigaction(int, struct sigaction *, struct sigaction *);
extern pid_t _wait4(pid_t, int *, int, struct rusage *);
+extern pid_t _waitpid(pid_t, int *, int);
--- a/include/bits/openbsd/sys.h
+++ b/include/bits/openbsd/sys.h
@@ -27,3 +27,4 @@
extern int _kill(pid_t, int);
extern int _sigaction(int, struct sigaction *, struct sigaction *);
extern pid_t _wait4(pid_t, int *, int, struct rusage *);
+extern pid_t _waitpid(pid_t, int *, int);
--- a/src/libc/arch/Makefile
+++ b/src/libc/arch/Makefile
@@ -15,11 +15,14 @@
linux\
posix\
-POSIX =\
+BSD =\
netbsd\
openbsd\
darwin\
dragonfly\
+
+POSIX =\
+ $(BSD)\
linux\
include $(PROJECTDIR)/scripts/rules.mk
@@ -30,3 +33,4 @@
all: $(ARCH) $(SYS)
$(POSIX): posix
+$(BSD): bsd
--- /dev/null
+++ b/src/libc/arch/bsd/Makefile
@@ -1,0 +1,11 @@
+.POSIX:
+PROJECTDIR = ../../../..
+include $(PROJECTDIR)/scripts/rules.mk
+include ../../rules.mk
+
+OBJS=\
+ _waitpid.$O\
+
+all: $(OBJS)
+
+include deps.mk
--- /dev/null
+++ b/src/libc/arch/bsd/_waitpid.c
@@ -1,0 +1,9 @@
+#include <stddef.h>
+
+#include <sys.h>
+
+int
+_waitpid(pid_t pid, int *status, int options)
+{
+ return _wait4(pid, status, options, NULL);
+}
--- /dev/null
+++ b/src/libc/arch/bsd/deps.mk
@@ -1,0 +1,1 @@
+#deps
--- a/src/libc/arch/linux/Makefile
+++ b/src/libc/arch/linux/Makefile
@@ -7,6 +7,7 @@
_brk.$O\
_getheap.$O\
_sigaction.$O\
+ _waitpid.$O\
all: $(OBJS)
--- /dev/null
+++ b/src/libc/arch/linux/_waitpid.c
@@ -1,0 +1,1 @@
+#include "../bsd/_waitpid.c"
--- a/src/libc/objs/amd64-linux.mk
+++ b/src/libc/objs/amd64-linux.mk
@@ -34,6 +34,7 @@
arch/linux/_brk.$O\
arch/linux/_getheap.$O\
arch/linux/_sigaction.$O\
+ arch/linux/_waitpid.$O\
arch/posix/_open.$O\
arch/posix/_systime.$O\
arch/posix/_tzone.$O\
--- a/src/libc/objs/amd64-netbsd.mk
+++ b/src/libc/objs/amd64-netbsd.mk
@@ -26,6 +26,7 @@
arch/amd64/strchr.$O\
arch/amd64/strcmp.$O\
arch/amd64/strcpy.$O\
+ arch/bsd/_waitpid.$O\
arch/netbsd/_sigaction.$O\
arch/posix/_getheap.$O\
arch/posix/_open.$O\
--- a/src/libc/objs/amd64-openbsd.mk
+++ b/src/libc/objs/amd64-openbsd.mk
@@ -26,6 +26,7 @@
arch/amd64/strchr.$O\
arch/amd64/strcmp.$O\
arch/amd64/strcpy.$O\
+ arch/bsd/_waitpid.$O\
arch/posix/_getheap.$O\
arch/posix/_open.$O\
arch/posix/_systime.$O\