Introduction
Introduction Statistics Contact Development Disclaimer Help
wait.c - 9base - revived minimalist port of Plan 9 userland to Unix
git clone git://git.suckless.org/9base
Log
Files
Refs
README
LICENSE
---
wait.c (813B)
---
1 #include <u.h>
2 #include <libc.h>
3
4 static Waitmsg*
5 _wait(int n, char *buf)
6 {
7 int l;
8 char *fld[5];
9 Waitmsg *w;
10
11 if(n <= 0)
12 return nil;
13 buf[n] = '\0';
14 if(tokenize(buf, fld, nelem(fld)) != nelem(fld)){
15 werrstr("couldn't parse wait message");
16 return nil;
17 }
18 l = strlen(fld[4])+1;
19 w = malloc(sizeof(Waitmsg)+l);
20 if(w == nil)
21 return nil;
22 w->pid = atoi(fld[0]);
23 w->time[0] = atoi(fld[1]);
24 w->time[1] = atoi(fld[2]);
25 w->time[2] = atoi(fld[3]);
26 w->msg = (char*)&w[1];
27 memmove(w->msg, fld[4], l);
28 return w;
29 }
30
31 Waitmsg*
32 wait(void)
33 {
34 char buf[256];
35
36 return _wait(await(buf, sizeof buf-1), buf);
37 }
38
39 Waitmsg*
40 waitnohang(void)
41 {
42 char buf[256];
43
44 return _wait(awaitnohang(buf, sizeof buf-1), buf);
45 }
46
47 Waitmsg*
48 waitfor(int pid)
49 {
50 char buf[256];
51
52 return _wait(awaitfor(pid, buf, sizeof buf-1), buf);
53 }
54
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.