waitpid.c 313 B

123456789101112131415161718192021
  1. #include <u.h>
  2. #include <libc.h>
  3. #include <fcall.h>
  4. int
  5. waitpid(void)
  6. {
  7. int n;
  8. char buf[512], *fld[5];
  9. n = await(buf, sizeof buf-1);
  10. if(n <= 0)
  11. return -1;
  12. buf[n] = '\0';
  13. if(tokenize(buf, fld, nelem(fld)) != nelem(fld)){
  14. werrstr("couldn't parse wait message");
  15. return -1;
  16. }
  17. return atoi(fld[0]);
  18. }