From f084cc9a342aa3d08054a5a930833b390a063bcd Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Sat, 29 Oct 2005 21:39:47 +1000 Subject: [SIGNAL] Added default implementation of strsignal klibc doesn't have strsignal but it does have sys_siglist. --- ChangeLog | 1 + configure.ac | 4 ++-- src/jobs.c | 1 + src/system.c | 14 ++++++++++++++ src/system.h | 4 ++++ 5 files changed, 22 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1f90a2a..3737c89 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,6 +11,7 @@ * Added getpwhome as a wrapper for getpwnam. * Fixed gcc 4.0 compilation problems. * Added missing system.h inclusion for mempcpy. + * Added default implementation of strsignal. 2005-10-26 Herbert Xu diff --git a/configure.ac b/configure.ac index bdce1b6..424ffee 100644 --- a/configure.ac +++ b/configure.ac @@ -23,8 +23,8 @@ dnl Checks for libraries. dnl Checks for header files. dnl Checks for library functions. -AC_CHECK_FUNCS(bsearch mempcpy getpwnam sigsetmask stpcpy strchrnul strtoimax \ - strtoumax) +AC_CHECK_FUNCS(bsearch mempcpy getpwnam sigsetmask stpcpy strchrnul strsignal \ + strtoimax strtoumax) dnl Check for klibc signal. AC_CHECK_FUNC(signal) diff --git a/src/jobs.c b/src/jobs.c index d5ea156..158d4e4 100644 --- a/src/jobs.c +++ b/src/jobs.c @@ -65,6 +65,7 @@ #include "memalloc.h" #include "error.h" #include "mystring.h" +#include "system.h" /* mode flags for set_curjob */ #define CUR_DELETE 2 diff --git a/src/system.c b/src/system.c index d375de0..d986efd 100644 --- a/src/system.c +++ b/src/system.c @@ -26,7 +26,9 @@ * SUCH DAMAGE. */ +#include #include +#include "output.h" #include "system.h" #ifndef HAVE_MEMPCPY @@ -53,6 +55,18 @@ char *strchrnul(const char *s, int c) } #endif +#ifndef HAVE_STRSIGNAL +char *strsignal(int sig) +{ + static char buf[19]; + + if ((unsigned)sig < NSIG && sys_siglist[sig]) + return (char *)sys_siglist[sig]; + fmtstr(buf, sizeof(buf), "Signal %d", sig); + return buf; +} +#endif + #ifndef HAVE_BSEARCH void *bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (*cmp)(const void *, const void *)) diff --git a/src/system.h b/src/system.h index d686024..0842675 100644 --- a/src/system.h +++ b/src/system.h @@ -51,6 +51,10 @@ char *stpcpy(char *, const char *); char *strchrnul(const char *, int); #endif +#ifndef HAVE_STRSIGNAL +char *strsignal(int); +#endif + #ifndef HAVE_STRTOIMAX #define strtoimax strtoll #endif -- cgit 1.4.1