[ovs-dev] [PATCH 1/2] signals: Use sys_siglist[] instead of strsignal() for thread-safety.

Alex Wang alexw at nicira.com
Tue Jun 4 15:50:26 UTC 2013


Looks good to me. Thanks


On Wed, May 1, 2013 at 11:25 AM, Ben Pfaff <blp at nicira.com> wrote:

> strsignal() isn't thread-safety but sys_siglist[] is.  Also, according to
> the glibc manual, BSD has sys_siglist[] but not strsignal().
>
> Signed-off-by: Ben Pfaff <blp at nicira.com>
> ---
>  configure.ac  |    3 ++-
>  lib/signals.c |    8 ++++++--
>  2 files changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index 7af8afb..8364ea5 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -58,9 +58,10 @@ OVS_CHECK_DOT
>  OVS_CHECK_IF_PACKET
>  OVS_CHECK_IF_DL
>  OVS_CHECK_STRTOK_R
> +AC_CHECK_DECLS([sys_siglist], [], [], [[#include <signal.h>]])
>  AC_CHECK_MEMBERS([struct stat.st_mtim.tv_nsec, struct stat.st_mtimensec],
>    [], [], [[#include <sys/stat.h>]])
> -AC_CHECK_FUNCS([mlockall strnlen strsignal getloadavg statvfs setmntent])
> +AC_CHECK_FUNCS([mlockall strnlen getloadavg statvfs setmntent])
>  AC_CHECK_HEADERS([mntent.h sys/statvfs.h linux/types.h linux/if_ether.h])
>
>  OVS_CHECK_PKIDIR
> diff --git a/lib/signals.c b/lib/signals.c
> index 06c2e75..09e0e09 100644
> --- a/lib/signals.c
> +++ b/lib/signals.c
> @@ -147,9 +147,13 @@ const char *
>  signal_name(int signum)
>  {
>      const char *name = NULL;
> -#ifdef HAVE_STRSIGNAL
> -    name = strsignal(signum);
> +
> +#if HAVE_DECL_SYS_SIGLIST
> +    if (signum >= 0 && signum < ARRAY_SIZE(sys_siglist)) {
> +        name = sys_siglist[signum];
> +    }
>  #endif
> +
>      if (!name) {
>          static char buffer[7 + INT_STRLEN(int) + 1];
>          sprintf(buffer, "signal %d", signum);
> --
> 1.7.2.5
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openvswitch.org/pipermail/ovs-dev/attachments/20130604/1dd666be/attachment-0003.html>


More information about the dev mailing list