vfs: check userland buffers before reading them.
[haiku.git] / src / libs / bsd / wait.c
blob57fc328992c55f736391ec627feea64e5d72f726
1 /*
2 * Copyright 2009, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Bruno Albuquerque, bga@bug-br.org.br
7 */
9 #include <OS.h>
11 #include <sys/resource.h>
12 #include <sys/wait.h>
15 extern pid_t _waitpid(pid_t pid, int* _status, int options,
16 team_usage_info *usage_info);
19 pid_t
20 wait3(int *status, int options, struct rusage *rusage)
22 return wait4(-1, status, options, rusage);
26 pid_t
27 wait4(pid_t pid, int *status, int options, struct rusage *rusage)
29 team_usage_info info;
30 pid_t waitPid = _waitpid(pid, status, options,
31 rusage != NULL ? &info : NULL);
32 if (waitPid != -1 && rusage != NULL) {
33 rusage->ru_utime.tv_sec = info.user_time / 1000000;
34 rusage->ru_utime.tv_usec = info.user_time % 1000000;
36 rusage->ru_stime.tv_sec = info.kernel_time / 1000000;
37 rusage->ru_stime.tv_usec = info.kernel_time % 1000000;
40 return waitPid;