waitpid.c 426 B

123456789101112131415161718192021222324252627
  1. #include <stdio.h>
  2. /*
  3. #include <sys/wait.h>
  4. #include <errno.h>
  5. int bmx_waitpid(pid_t pid) {
  6. int status;
  7. pid_t p = waitpid(pid, &status, WUNTRACED);
  8. if (p > 0) {
  9. if (WIFEXITED(status)) {
  10. return WEXITSTATUS(status);
  11. }
  12. if (WIFSIGNALED(status)) {
  13. return WTERMSIG(status);
  14. }
  15. } else {
  16. return errno * -1;
  17. }
  18. return -999;
  19. }
  20. */
  21. int bmx_system(const char * c) {
  22. return system(c);
  23. }