summaryrefslogtreecommitdiff
path: root/status.c
diff options
context:
space:
mode:
authorByron Rakitzis <byron@archone.tamu.edu>1994-03-07 00:00:01 +0000
committerToby Goodwin <toby@paccrat.org>2015-05-16 21:22:59 +0100
commit5556dde4d3ad4e34267320b1411fc090b18a24b0 (patch)
tree9d22c48c75bcd778f30cbb2e37b6dff6abb4f1d2 /status.c
parent26bb34cf036027dfa22dfae8d8fc2f6bfd6acb75 (diff)
beta: rc-1.5betadev1
Diffstat (limited to 'status.c')
-rw-r--r--status.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/status.c b/status.c
index 1b6325b..91252b0 100644
--- a/status.c
+++ b/status.c
@@ -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;