diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2013-03-09 16:45:56 +0100 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2013-03-09 19:26:21 +0100 |
commit | 9a6f5b24424e65d62600b0a1388174646af686b9 (patch) | |
tree | 2d47770325325e8457df36fc5e3422f133752231 | |
parent | 646dfa81025a89c50b81bf91dd95fd828606718d (diff) |
move signame() function to common.c to make it available to all modules
-rw-r--r-- | nslcd/common.c | 58 | ||||
-rw-r--r-- | nslcd/common.h | 3 | ||||
-rw-r--r-- | nslcd/nslcd.c | 55 |
3 files changed, 60 insertions, 56 deletions
diff --git a/nslcd/common.c b/nslcd/common.c index 2b67e6c..211be1b 100644 --- a/nslcd/common.c +++ b/nslcd/common.c @@ -3,7 +3,7 @@ This file is part of the nss-pam-ldapd library. Copyright (C) 2006 West Consulting - Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Arthur de Jong + Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Arthur de Jong This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -35,6 +35,7 @@ #include <string.h> #include <regex.h> #include <stdlib.h> +#include <signal.h> #include "nslcd.h" #include "common.h" @@ -58,6 +59,61 @@ int mysnprintf(char *buffer, size_t buflen, const char *format, ...) return ((res < 0) || (((size_t)res) >= buflen)); } +/* get a name of a signal with a given signal number */ +const char *signame(int signum) +{ + switch (signum) + { + case SIGHUP: return "SIGHUP"; /* Hangup detected */ + case SIGINT: return "SIGINT"; /* Interrupt from keyboard */ + case SIGQUIT: return "SIGQUIT"; /* Quit from keyboard */ + case SIGILL: return "SIGILL"; /* Illegal Instruction */ + case SIGABRT: return "SIGABRT"; /* Abort signal from abort(3) */ + case SIGFPE: return "SIGFPE"; /* Floating point exception */ + case SIGKILL: return "SIGKILL"; /* Kill signal */ + case SIGSEGV: return "SIGSEGV"; /* Invalid memory reference */ + case SIGPIPE: return "SIGPIPE"; /* Broken pipe */ + case SIGALRM: return "SIGALRM"; /* Timer signal from alarm(2) */ + case SIGTERM: return "SIGTERM"; /* Termination signal */ + case SIGUSR1: return "SIGUSR1"; /* User-defined signal 1 */ + case SIGUSR2: return "SIGUSR2"; /* User-defined signal 2 */ + case SIGCHLD: return "SIGCHLD"; /* Child stopped or terminated */ + case SIGCONT: return "SIGCONT"; /* Continue if stopped */ + case SIGSTOP: return "SIGSTOP"; /* Stop process */ + case SIGTSTP: return "SIGTSTP"; /* Stop typed at tty */ + case SIGTTIN: return "SIGTTIN"; /* tty input for background process */ + case SIGTTOU: return "SIGTTOU"; /* tty output for background process */ +#ifdef SIGBUS + case SIGBUS: return "SIGBUS"; /* Bus error */ +#endif +#ifdef SIGPOLL + case SIGPOLL: return "SIGPOLL"; /* Pollable event */ +#endif +#ifdef SIGPROF + case SIGPROF: return "SIGPROF"; /* Profiling timer expired */ +#endif +#ifdef SIGSYS + case SIGSYS: return "SIGSYS"; /* Bad argument to routine */ +#endif +#ifdef SIGTRAP + case SIGTRAP: return "SIGTRAP"; /* Trace/breakpoint trap */ +#endif +#ifdef SIGURG + case SIGURG: return "SIGURG"; /* Urgent condition on socket */ +#endif +#ifdef SIGVTALRM + case SIGVTALRM: return "SIGVTALRM"; /* Virtual alarm clock */ +#endif +#ifdef SIGXCPU + case SIGXCPU: return "SIGXCPU"; /* CPU time limit exceeded */ +#endif +#ifdef SIGXFSZ + case SIGXFSZ: return "SIGXFSZ"; /* File size limit exceeded */ +#endif + default: return "UNKNOWN"; + } +} + /* return the fully qualified domain name of the current host */ const char *getfqdn(void) { diff --git a/nslcd/common.h b/nslcd/common.h index e1a2037..fc44c43 100644 --- a/nslcd/common.h +++ b/nslcd/common.h @@ -60,6 +60,9 @@ int mysnprintf(char *buffer, size_t buflen, const char *format, ...) LIKE_PRINTF(3, 4); +/* get a name of a signal with a given signal number */ +const char *signame(int signum); + /* return the fully qualified domain name of the current host the returned value does not need to be freed but is re-used for every call */ diff --git a/nslcd/nslcd.c b/nslcd/nslcd.c index 3b85ff8..fc2237c 100644 --- a/nslcd/nslcd.c +++ b/nslcd/nslcd.c @@ -178,61 +178,6 @@ static void parse_cmdline(int argc, char *argv[]) } } -/* get a name of a signal with a given signal number */ -static const char *signame(int signum) -{ - switch (signum) - { - case SIGHUP: return "SIGHUP"; /* Hangup detected */ - case SIGINT: return "SIGINT"; /* Interrupt from keyboard */ - case SIGQUIT: return "SIGQUIT"; /* Quit from keyboard */ - case SIGILL: return "SIGILL"; /* Illegal Instruction */ - case SIGABRT: return "SIGABRT"; /* Abort signal from abort(3) */ - case SIGFPE: return "SIGFPE"; /* Floating point exception */ - case SIGKILL: return "SIGKILL"; /* Kill signal */ - case SIGSEGV: return "SIGSEGV"; /* Invalid memory reference */ - case SIGPIPE: return "SIGPIPE"; /* Broken pipe */ - case SIGALRM: return "SIGALRM"; /* Timer signal from alarm(2) */ - case SIGTERM: return "SIGTERM"; /* Termination signal */ - case SIGUSR1: return "SIGUSR1"; /* User-defined signal 1 */ - case SIGUSR2: return "SIGUSR2"; /* User-defined signal 2 */ - case SIGCHLD: return "SIGCHLD"; /* Child stopped or terminated */ - case SIGCONT: return "SIGCONT"; /* Continue if stopped */ - case SIGSTOP: return "SIGSTOP"; /* Stop process */ - case SIGTSTP: return "SIGTSTP"; /* Stop typed at tty */ - case SIGTTIN: return "SIGTTIN"; /* tty input for background process */ - case SIGTTOU: return "SIGTTOU"; /* tty output for background process */ -#ifdef SIGBUS - case SIGBUS: return "SIGBUS"; /* Bus error */ -#endif -#ifdef SIGPOLL - case SIGPOLL: return "SIGPOLL"; /* Pollable event */ -#endif -#ifdef SIGPROF - case SIGPROF: return "SIGPROF"; /* Profiling timer expired */ -#endif -#ifdef SIGSYS - case SIGSYS: return "SIGSYS"; /* Bad argument to routine */ -#endif -#ifdef SIGTRAP - case SIGTRAP: return "SIGTRAP"; /* Trace/breakpoint trap */ -#endif -#ifdef SIGURG - case SIGURG: return "SIGURG"; /* Urgent condition on socket */ -#endif -#ifdef SIGVTALRM - case SIGVTALRM: return "SIGVTALRM"; /* Virtual alarm clock */ -#endif -#ifdef SIGXCPU - case SIGXCPU: return "SIGXCPU"; /* CPU time limit exceeded */ -#endif -#ifdef SIGXFSZ - case SIGXFSZ: return "SIGXFSZ"; /* File size limit exceeded */ -#endif - default: return "UNKNOWN"; - } -} - /* signal handler for closing down */ static void sigexit_handler(int signum) { |