diff options
| author | Byron Rakitzis <byron@archone.tamu.edu> | 1994-03-07 00:00:01 +0000 |
|---|---|---|
| committer | Toby Goodwin <toby@paccrat.org> | 2015-05-16 21:22:59 +0100 |
| commit | 5556dde4d3ad4e34267320b1411fc090b18a24b0 (patch) | |
| tree | 9d22c48c75bcd778f30cbb2e37b6dff6abb4f1d2 /status.c | |
| parent | 26bb34cf036027dfa22dfae8d8fc2f6bfd6acb75 (diff) | |
beta: rc-1.5betadev1
Diffstat (limited to 'status.c')
| -rw-r--r-- | status.c | 34 |
1 files changed, 21 insertions, 13 deletions
@@ -80,27 +80,35 @@ extern void statprint(int pid, int i) { /* prepare a list to be passed back. Used whenever $status is dereferenced */ extern List *sgetstatus() { - List *r; + List *r = NULL; int i; - for (r = NULL, i = 0; i < pipelength; i++) { + + for (i = 0; i < pipelength; i++) { List *q = nnew(List); - int s = statuses[i]; - int t; + q->w = strstatus(statuses[i]); + q->m = NULL; q->n = r; r = q; - if ((t = s & 0x7f) != 0) { - const char *core = (s & 0x80) ? "+core" : ""; - if (t < NUMOFSIGNALS && *signals[t].name != '\0') - r->w = nprint("%s%s", signals[t].name, core); - else - r->w = nprint("-%d%s", t, core); /* unknown signals are negated */ - } else - r->w = nprint("%d", (s >> 8) & 0xff); - r->m = NULL; } + return r; } +/* return status as a string (used above and for bqstatus) */ + +extern char *strstatus(int s) { + int t = s & 0x7f; + + if (t != 0) { + const char *core = (s & 0x80) ? "+core" : ""; + if (t < NUMOFSIGNALS && *signals[t].name != '\0') + return nprint("%s%s", signals[t].name, core); + else + return nprint("-%d%s", t, core); /* unknown signals are negated */ + } else + return nprint("%d", (s >> 8) & 0xff); +} + extern void ssetstatus(char **av) { int i, j, k, l; bool found; |