summaryrefslogtreecommitdiffstats
path: root/bin/sh
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2012-12-25 14:17:09 +0000
committerjilles <jilles@FreeBSD.org>2012-12-25 14:17:09 +0000
commitda771ef7de845c8c8a2c112aa2c3a4f225bf64ff (patch)
tree751357e16760a4cbd1dda64749da79c5080283a4 /bin/sh
parent7ccc77532c6e05b3e2eee10cc7a5cacda533fda0 (diff)
downloadFreeBSD-src-da771ef7de845c8c8a2c112aa2c3a4f225bf64ff.zip
FreeBSD-src-da771ef7de845c8c8a2c112aa2c3a4f225bf64ff.tar.gz
sh: Prefer strsignal() to accessing sys_siglist directly.
Accessing sys_siglist directly requires rtld to copy it from libc to the sh executable's BSS. Also, strsignal() will put in the signal number for unknown signals (FreeBSD-specific) so we need not do that ourselves. Unfortunately, there is no function for sys_signame.
Diffstat (limited to 'bin/sh')
-rw-r--r--bin/sh/jobs.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/bin/sh/jobs.c b/bin/sh/jobs.c
index 05e2e88..02cf6e8 100644
--- a/bin/sh/jobs.c
+++ b/bin/sh/jobs.c
@@ -298,6 +298,7 @@ showjob(struct job *jp, int mode)
{
char s[64];
char statestr[64];
+ const char *sigstr;
struct procstat *ps;
struct job *j;
int col, curr, i, jobno, prev, procno;
@@ -324,8 +325,9 @@ showjob(struct job *jp, int mode)
i = WSTOPSIG(ps->status);
else
i = -1;
- if (i > 0 && i < sys_nsig && sys_siglist[i])
- strcpy(statestr, sys_siglist[i]);
+ sigstr = strsignal(i);
+ if (sigstr != NULL)
+ strcpy(statestr, sigstr);
else
strcpy(statestr, "Suspended");
#endif
@@ -337,10 +339,11 @@ showjob(struct job *jp, int mode)
WEXITSTATUS(ps->status));
} else {
i = WTERMSIG(ps->status);
- if (i > 0 && i < sys_nsig && sys_siglist[i])
- strcpy(statestr, sys_siglist[i]);
+ sigstr = strsignal(i);
+ if (sigstr != NULL)
+ strcpy(statestr, sigstr);
else
- fmtstr(statestr, 64, "Signal %d", i);
+ strcpy(statestr, "Unknown signal");
if (WCOREDUMP(ps->status))
strcat(statestr, " (core dumped)");
}
@@ -1019,6 +1022,7 @@ dowait(int mode, struct job *job)
struct procstat *sp;
struct job *jp;
struct job *thisjob;
+ const char *sigstr;
int done;
int stopped;
int sig;
@@ -1129,10 +1133,11 @@ dowait(int mode, struct job *job)
coredump = WCOREDUMP(sp->status);
}
if (sig > 0 && sig != SIGINT && sig != SIGPIPE) {
- if (sig < sys_nsig && sys_siglist[sig])
- out2str(sys_siglist[sig]);
+ sigstr = strsignal(sig);
+ if (sigstr != NULL)
+ out2str(sigstr);
else
- outfmt(out2, "Signal %d", sig);
+ out2str("Unknown signal");
if (coredump)
out2str(" (core dumped)");
out2c('\n');
OpenPOWER on IntegriCloud