Date: Tue, 25 Dec 2012 14:17:10 +0000 (UTC) From: Jilles Tjoelker <jilles@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r244682 - head/bin/sh Message-ID: <201212251417.qBPEHAQC070177@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jilles Date: Tue Dec 25 14:17:09 2012 New Revision: 244682 URL: http://svnweb.freebsd.org/changeset/base/244682 Log: 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. Modified: head/bin/sh/jobs.c Modified: head/bin/sh/jobs.c ============================================================================== --- head/bin/sh/jobs.c Tue Dec 25 14:08:13 2012 (r244681) +++ head/bin/sh/jobs.c Tue Dec 25 14:17:09 2012 (r244682) @@ -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');
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201212251417.qBPEHAQC070177>