1 /* 2 * Copyright 2009, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Bruno Albuquerque, bga@bug-br.org.br 7 */ 8 9 #include <OS.h> 10 11 #include <sys/resource.h> 12 #include <sys/wait.h> 13 14 15 extern pid_t _waitpid(pid_t pid, int* _status, int options, 16 team_usage_info *usage_info); 17 18 19 pid_t 20 wait3(int *status, int options, struct rusage *rusage) 21 { 22 return wait4(-1, status, options, rusage); 23 } 24 25 26 pid_t 27 wait4(pid_t pid, int *status, int options, struct rusage *rusage) 28 { 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; 35 36 rusage->ru_stime.tv_sec = info.kernel_time / 1000000; 37 rusage->ru_stime.tv_usec = info.kernel_time % 1000000; 38 } 39 40 return waitPid; 41 } 42 43