1
0

wait4_time32.c 938 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #define _BSD_SOURCE
  2. #include "time32.h"
  3. #include <string.h>
  4. #include <stddef.h>
  5. #include <sys/wait.h>
  6. struct compat_rusage {
  7. struct timeval32 ru_utime;
  8. struct timeval32 ru_stime;
  9. long ru_maxrss;
  10. long ru_ixrss;
  11. long ru_idrss;
  12. long ru_isrss;
  13. long ru_minflt;
  14. long ru_majflt;
  15. long ru_nswap;
  16. long ru_inblock;
  17. long ru_oublock;
  18. long ru_msgsnd;
  19. long ru_msgrcv;
  20. long ru_nsignals;
  21. long ru_nvcsw;
  22. long ru_nivcsw;
  23. };
  24. pid_t __wait4_time32(pid_t pid, int *status, int options, struct compat_rusage *usage)
  25. {
  26. struct rusage ru;
  27. int r = wait4(pid, status, options, usage ? &ru : 0);
  28. if (!r && usage) {
  29. usage->ru_utime.tv_sec = ru.ru_utime.tv_sec;
  30. usage->ru_utime.tv_usec = ru.ru_utime.tv_usec;
  31. usage->ru_stime.tv_sec = ru.ru_stime.tv_sec;
  32. usage->ru_stime.tv_usec = ru.ru_stime.tv_usec;
  33. memcpy(&usage->ru_maxrss, &ru.ru_maxrss,
  34. sizeof(struct compat_rusage) -
  35. offsetof(struct compat_rusage, ru_maxrss));
  36. }
  37. return r;
  38. }