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