about summary refs log tree commit diff
path: root/src/linux/wait4.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2011-02-12 00:22:29 -0500
committerRich Felker <dalias@aerifal.cx>2011-02-12 00:22:29 -0500
commit0b44a0315b47dd8eced9f3b7f31580cf14bbfc01 (patch)
tree6eaef0d8a720fa3da580de87b647fff796fe80b3 /src/linux/wait4.c
downloadmusl-0b44a0315b47dd8eced9f3b7f31580cf14bbfc01.tar.gz
musl-0b44a0315b47dd8eced9f3b7f31580cf14bbfc01.tar.xz
musl-0b44a0315b47dd8eced9f3b7f31580cf14bbfc01.zip
initial check-in, version 0.5.0 v0.5.0
Diffstat (limited to 'src/linux/wait4.c')
-rw-r--r--src/linux/wait4.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/linux/wait4.c b/src/linux/wait4.c
new file mode 100644
index 00000000..dda942d3
--- /dev/null
+++ b/src/linux/wait4.c
@@ -0,0 +1,19 @@
+#include <sys/wait.h>
+#include <sys/resource.h>
+#include <string.h>
+#define SYSCALL_STANDALONE
+#include "syscall.h"
+
+pid_t wait4(pid_t pid, int *status, int options, struct rusage *usage)
+{
+	pid_t ret = syscall4(__NR_wait4, pid, (long)status, options, (long)usage);
+	/* Fixup kernel time_t... */
+	if (usage) {
+		long kusage[4];
+		memcpy(kusage, usage, sizeof kusage);
+		memmove((struct timeval *)usage + 2, (long *)usage + 4, sizeof *usage - 2*sizeof(struct timeval));
+		usage->ru_utime = (struct timeval){ kusage[0], kusage[1] };
+		usage->ru_stime = (struct timeval){ kusage[2], kusage[3] };
+	}
+	return ret;
+}