]> git.lizzy.rs Git - plan9front.git/blob - sys/src/libc/9sys/wait.c
allow # netpath in dial string
[plan9front.git] / sys / src / libc / 9sys / wait.c
1 #include <u.h>
2 #include <libc.h>
3 #include <fcall.h>
4
5 Waitmsg*
6 wait(void)
7 {
8         int n, l;
9         char buf[512], *fld[5];
10         Waitmsg *w;
11
12         n = await(buf, sizeof buf-1);
13         if(n < 0)
14                 return nil;
15         buf[n] = '\0';
16         if(tokenize(buf, fld, nelem(fld)) != nelem(fld)){
17                 werrstr("couldn't parse wait message");
18                 return nil;
19         }
20         l = strlen(fld[4])+1;
21         w = malloc(sizeof(Waitmsg)+l);
22         if(w == nil)
23                 return nil;
24         w->pid = atoi(fld[0]);
25         w->time[0] = atoi(fld[1]);
26         w->time[1] = atoi(fld[2]);
27         w->time[2] = atoi(fld[3]);
28         w->msg = (char*)&w[1];
29         memmove(w->msg, fld[4], l);
30         return w;
31 }
32