8 #include <sys/resource.h>
18 SIGILL, "sys: trap: illegal instruction",
19 SIGTRAP, "sys: trace trap",
20 SIGABRT, "sys: abort",
22 SIGEMT, "sys: emulate instruction executed",
24 SIGFPE, "sys: fp: trap",
26 SIGBUS, "sys: bus error",
27 SIGSEGV, "sys: segmentation violation",
30 SIGURG, "sys: urgent condition on socket",
34 SIGCHLD, "sys: child",
37 SIGIO, "sys: i/o possible on fd",
38 SIGXCPU, "sys: cpu time limit exceeded",
39 SIGXFSZ, "sys: file size limit exceeded",
40 SIGVTALRM, "sys: virtual time alarm",
41 SIGPROF, "sys: profiling timer alarm",
42 SIGWINCH, "sys: window size change",
44 SIGINFO, "sys: status request",
48 SIGPIPE, "sys: write on closed pipe",
52 _p9sigstr(int sig, char *tmp)
56 for(i=0; i<nelem(tab); i++)
61 sprint(tmp, "sys: signal %d", sig);
70 for(i=0; i<nelem(tab); i++)
71 if(strcmp(s, tab[i].str) == 0)
77 _await(char *str, int n, int opt)
81 char buf[128], tmp[64];
85 pid = wait3(&status, opt, &ru);
88 u = ru.ru_utime.tv_sec*1000+((ru.ru_utime.tv_usec+500)/1000);
89 s = ru.ru_stime.tv_sec*1000+((ru.ru_stime.tv_usec+500)/1000);
90 if(WIFEXITED(status)){
91 status = WEXITSTATUS(status);
93 snprint(buf, sizeof buf, "%d %lud %lud %lud %d", pid, u, s, u+s, status);
95 snprint(buf, sizeof buf, "%d %lud %lud %lud ''", pid, u, s, u+s, status);
96 strecpy(str, str+n, buf);
99 if(WIFSIGNALED(status)){
100 cd = WCOREDUMP(status);
102 snprint(buf, sizeof buf, "%d %lud %lud %lud '%s'", pid, u, s, u+s, _p9sigstr(WTERMSIG(status), tmp));
103 strecpy(str, str+n, buf);
110 await(char *str, int n)
112 return _await(str, n, 0);
116 awaitnohang(char *str, int n)
118 return _await(str, n, WNOHANG);