xref: /plan9/sys/src/libc/9sys/waitpid.c (revision ec59a3ddbfceee0efe34584c2c9981a5e5ff1ec4)
1 #include <u.h>
2 #include <libc.h>
3 #include <fcall.h>
4 
5 int
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