9base

revived minimalist port of Plan 9 userland to Unix
git clone git://git.suckless.org/9base
Log | Files | Refs | README | LICENSE

waitpid.c (294B)


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