wait.c 595 B

1234567891011121314151617181920212223242526
  1. #include "wait.h"
  2. #include <libsystem/syscall.h>
  3. /**
  4. * @brief 等待所有子进程退出
  5. *
  6. * @param stat_loc 返回的子进程结束状态
  7. * @return pid_t
  8. */
  9. pid_t wait(int *stat_loc)
  10. {
  11. return waitpid((pid_t)(-1), stat_loc, 0);
  12. }
  13. /**
  14. * @brief 等待指定pid的子进程退出
  15. *
  16. * @param pid 子进程的pid
  17. * @param stat_loc 返回的子进程结束状态
  18. * @param options 额外的控制选项
  19. * @return pid_t
  20. */
  21. pid_t waitpid(pid_t pid, int *stat_loc, int options)
  22. {
  23. return (pid_t)syscall_invoke(SYS_WAIT4, (uint64_t)pid, (uint64_t)stat_loc, options, 0, 0, 0, 0, 0);
  24. }