Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Add the new signalname/signalnext/signalnumber interface to ...



details:   https://anonhg.NetBSD.org/src/rev/e8fdffaade8d
branches:  trunk
changeset: 823792:e8fdffaade8d
user:      kre <kre%NetBSD.org@localhost>
date:      Tue May 09 11:14:16 2017 +0000

description:
Add the new signalname/signalnext/signalnumber interface to libc.

This as discussed on current-users in the thread
entitled:
  Proposal: new libc/libutil functions to map SIGXXXX <-> "XXXX"
that can be found (starting at):
  http://mail-index.netbsd.org/current-users/2017/04/28/msg031600.html

These functions provide the mechanism to enable applications
to divorce themselves from internal details of the signal
implementation.

Libc minor bumped, prototypes in <signal.h>, sets lists updated (and sorted).

One and all: feel free to improve the sources & man page (etc), but
please do not change the function signatures without discussion.

diffstat:

 distrib/sets/lists/base/shl.mi  |    6 +-
 distrib/sets/lists/comp/mi      |   12 ++-
 distrib/sets/lists/debug/shl.mi |    6 +-
 include/signal.h                |    9 ++-
 lib/libc/gen/Makefile.inc       |   11 +-
 lib/libc/gen/signalname.3       |  133 ++++++++++++++++++++++++++++++++++++++++
 lib/libc/gen/signalname.c       |   44 +++++++++++++
 lib/libc/gen/signalnext.c       |   49 ++++++++++++++
 lib/libc/gen/signalnumber.c     |   52 +++++++++++++++
 lib/libc/shlib_version          |    4 +-
 10 files changed, 309 insertions(+), 17 deletions(-)

diffs (truncated from 463 to 300 lines):

diff -r 9d787dbd8c4f -r e8fdffaade8d distrib/sets/lists/base/shl.mi
--- a/distrib/sets/lists/base/shl.mi    Tue May 09 06:41:56 2017 +0000
+++ b/distrib/sets/lists/base/shl.mi    Tue May 09 11:14:16 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: shl.mi,v 1.812 2017/05/06 19:54:41 christos Exp $
+# $NetBSD: shl.mi,v 1.813 2017/05/09 11:14:16 kre Exp $
 #
 # Note:        Don't delete entries from here - mark them as "obsolete" instead,
 #      unless otherwise stated below.
@@ -18,7 +18,7 @@
 ./lib/libblacklist.so.0.0                      base-sys-shlib          dynamicroot
 ./lib/libc.so                                  base-sys-shlib          dynamicroot
 ./lib/libc.so.12                               base-sys-shlib          dynamicroot
-./lib/libc.so.12.206                           base-sys-shlib          dynamicroot
+./lib/libc.so.12.207                           base-sys-shlib          dynamicroot
 ./lib/libcrypt.so                              base-sys-shlib          dynamicroot
 ./lib/libcrypt.so.1                            base-sys-shlib          dynamicroot
 ./lib/libcrypt.so.1.0                          base-sys-shlib          dynamicroot
@@ -214,7 +214,7 @@
 ./usr/lib/libc++.so.1.0                                base-sys-shlib          compatfile,libcxx
 ./usr/lib/libc.so                              base-sys-shlib          compatfile
 ./usr/lib/libc.so.12                           base-sys-shlib          compatfile
-./usr/lib/libc.so.12.206                       base-sys-shlib          compatfile
+./usr/lib/libc.so.12.207                       base-sys-shlib          compatfile
 ./usr/lib/libcdk.so                            base-obsolete           compatfile,obsolete
 ./usr/lib/libcom_err.so                                base-krb5-shlib         compatfile,kerberos
 ./usr/lib/libcom_err.so.8                      base-krb5-shlib         compatfile,kerberos
diff -r 9d787dbd8c4f -r e8fdffaade8d distrib/sets/lists/comp/mi
--- a/distrib/sets/lists/comp/mi        Tue May 09 06:41:56 2017 +0000
+++ b/distrib/sets/lists/comp/mi        Tue May 09 11:14:16 2017 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: mi,v 1.2130 2017/05/01 23:33:07 pgoyette Exp $
+#      $NetBSD: mi,v 1.2131 2017/05/09 11:14:16 kre Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 ./etc/mtree/set.comp                           comp-sys-root
@@ -3455,10 +3455,10 @@
 ./usr/lib/librumpdev_scsitest_p.a              comp-obsolete           obsolete
 ./usr/lib/librumpdev_sysmon.a                  comp-c-lib              rump
 ./usr/lib/librumpdev_sysmon_p.a                        comp-c-proflib          rump,profile
+./usr/lib/librumpdev_ualea.a                   comp-c-lib              rump
+./usr/lib/librumpdev_ualea_p.a                 comp-c-proflib          rump,profile
 ./usr/lib/librumpdev_ubt.a                     comp-c-lib              rump
 ./usr/lib/librumpdev_ubt_p.a                   comp-c-proflib          rump,profile
-./usr/lib/librumpdev_ualea.a                   comp-c-lib              rump
-./usr/lib/librumpdev_ualea_p.a                 comp-c-proflib          rump,profile
 ./usr/lib/librumpdev_ucom.a                    comp-c-lib              rump
 ./usr/lib/librumpdev_ucom_p.a                  comp-c-proflib          rump,profile
 ./usr/lib/librumpdev_ugenhc.a                  comp-c-lib              rump
@@ -16633,6 +16633,9 @@
 ./usr/share/man/html3/signal_initialized.html  comp-obsolete           obsolete
 ./usr/share/man/html3/signal_pending.html      comp-obsolete           obsolete
 ./usr/share/man/html3/signal_set.html          comp-obsolete           obsolete
+./usr/share/man/html3/signalname.html          comp-c-htmlman          html
+./usr/share/man/html3/signalnext.html          comp-c-htmlman          html
+./usr/share/man/html3/signalnumber.html                comp-c-htmlman          html
 ./usr/share/man/html3/signbit.html             comp-c-htmlman          html
 ./usr/share/man/html3/significand.html         comp-c-htmlman          html
 ./usr/share/man/html3/significandf.html                comp-c-htmlman          html
@@ -24159,6 +24162,9 @@
 ./usr/share/man/man3/signal_initialized.3      comp-obsolete           obsolete
 ./usr/share/man/man3/signal_pending.3          comp-obsolete           obsolete
 ./usr/share/man/man3/signal_set.3              comp-obsolete           obsolete
+./usr/share/man/man3/signalname.3              comp-c-man              .man
+./usr/share/man/man3/signalnext.3              comp-c-man              .man
+./usr/share/man/man3/signalnumber.3            comp-c-man              .man
 ./usr/share/man/man3/signbit.3                 comp-c-man              .man
 ./usr/share/man/man3/significand.3             comp-c-man              .man
 ./usr/share/man/man3/significandf.3            comp-c-man              .man
diff -r 9d787dbd8c4f -r e8fdffaade8d distrib/sets/lists/debug/shl.mi
--- a/distrib/sets/lists/debug/shl.mi   Tue May 09 06:41:56 2017 +0000
+++ b/distrib/sets/lists/debug/shl.mi   Tue May 09 11:14:16 2017 +0000
@@ -1,8 +1,8 @@
-# $NetBSD: shl.mi,v 1.171 2017/05/07 00:43:01 htodd Exp $
+# $NetBSD: shl.mi,v 1.172 2017/05/09 11:14:16 kre Exp $
 ./usr/lib/libbfd_g.a                                           comp-c-debuglib debuglib,compatfile,binutils
 ./usr/libdata/debug/lib                                                base-sys-usr    debug,dynamicroot,compatdir
 ./usr/libdata/debug/lib/libblacklist.so.0.0.debug              comp-sys-debug  debug,dynamicroot
-./usr/libdata/debug/lib/libc.so.12.206.debug                   comp-sys-debug  debug,dynamicroot
+./usr/libdata/debug/lib/libc.so.12.207.debug                   comp-sys-debug  debug,dynamicroot
 ./usr/libdata/debug/lib/libcrypt.so.1.0.debug                  comp-sys-debug  debug,dynamicroot
 ./usr/libdata/debug/lib/libcrypto.so.12.0.debug                        comp-sys-debug  debug,dynamicroot,crypto
 ./usr/libdata/debug/lib/libdevmapper.so.1.0.debug              comp-sys-debug  debug,dynamicroot,lvm
@@ -70,7 +70,7 @@
 ./usr/libdata/debug/usr/lib/libbsdmalloc.so.0.0.debug          comp-sys-debug  debug,compatfile
 ./usr/libdata/debug/usr/lib/libbz2.so.1.1.debug                        comp-sys-debug  debug,compatfile
 ./usr/libdata/debug/usr/lib/libc++.so.1.0.debug                        comp-sys-debug  debug,compatfile,libcxx
-./usr/libdata/debug/usr/lib/libc.so.12.206.debug               comp-sys-debug  debug,compatfile
+./usr/libdata/debug/usr/lib/libc.so.12.207.debug               comp-sys-debug  debug,compatfile
 ./usr/libdata/debug/usr/lib/libcom_err.so.8.0.debug            comp-krb5-debug debug,compatfile,kerberos
 ./usr/libdata/debug/usr/lib/libcrypt.so.1.0.debug              comp-sys-debug  debug,compatfile
 ./usr/libdata/debug/usr/lib/libcrypto.so.12.0.debug            comp-crypto-debug       debug,compatfile,crypto
diff -r 9d787dbd8c4f -r e8fdffaade8d include/signal.h
--- a/include/signal.h  Tue May 09 06:41:56 2017 +0000
+++ b/include/signal.h  Tue May 09 11:14:16 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: signal.h,v 1.55 2015/07/31 12:51:32 kamil Exp $        */
+/*     $NetBSD: signal.h,v 1.56 2017/05/09 11:14:16 kre Exp $  */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -56,6 +56,13 @@
 
 __BEGIN_DECLS
 int    raise(int);
+
+#if defined(_NETBSD_SOURCE)
+const char *signalname(int);
+int signalnext(int);
+int signalnumber(const char *);
+#endif
+
 #if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
     defined(_NETBSD_SOURCE)
 int    kill(pid_t, int);
diff -r 9d787dbd8c4f -r e8fdffaade8d lib/libc/gen/Makefile.inc
--- a/lib/libc/gen/Makefile.inc Tue May 09 06:41:56 2017 +0000
+++ b/lib/libc/gen/Makefile.inc Tue May 09 11:14:16 2017 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.inc,v 1.198 2017/02/07 19:29:40 kamil Exp $
+#      $NetBSD: Makefile.inc,v 1.199 2017/05/09 11:14:16 kre Exp $
 #      from: @(#)Makefile.inc  8.6 (Berkeley) 5/4/95
 
 # gen sources
@@ -29,8 +29,8 @@
        rewinddir.c scandir.c seekdir.c setdomainname.c \
        sethostname.c setjmperr.c setmode.c setproctitle.c setprogname.c \
        shquote.c shquotev.c sighold.c sigignore.c siginterrupt.c \
-       siglist.c signal.c signame.c sigrelse.c \
-       sigset.c sigsetops.c sleep.c \
+       siglist.c signal.c signalname.c signalnext.c signalnumber.c \
+       signame.c sigrelse.c sigset.c sigsetops.c sleep.c \
        stringlist.c sysconf.c sysctl.c sysctlbyname.c sysctlgetmibinfo.c \
        sysctlnametomib.c syslog.c syslog_ss.c telldir.c time.c timespec_get.c \
        times.c toascii.c tolower_.c ttyname.c ttyslot.c toupper_.c ualarm.c \
@@ -79,8 +79,8 @@
        psignal.3 pwcache.3 pthread_atfork.3 \
        raise.3 randomid.3 realpath.3 scandir.3 setjmp.3 setmode.3 \
        setproctitle.3 shquote.3 sighold.3 sigignore.3 siginterrupt.3 \
-       signal.3 signbit.3 sigrelse.3 sigset.3 sigsetops.3 sleep.3 \
-       stringlist.3 sysconf.3 sysctl.3 syslog.3 \
+       signal.3 signalname.3 signbit.3 sigrelse.3 sigset.3 sigsetops.3 \
+       sleep.3 stringlist.3 sysconf.3 sysctl.3 syslog.3 \
        time.3 timespec_get.3 times.3 timezone.3 toascii.3 tolower.3 \
        toupper.3 ttyname.3 \
        ualarm.3 ulimit.3 uname.3 unvis.3 usleep.3 utime.3 valloc.3 vis.3 \
@@ -171,6 +171,7 @@
        setjmp.3 longjmperror.3 setjmp.3 sigsetjmp.3 setjmp.3 siglongjmp.3
 MLINKS+=setmode.3 getmode.3
 MLINKS+=shquote.3 shquotev.3
+MLINKS+=signalname.3 signalnext.3 signalname.3 signalnumber.3
 MLINKS+=sigsetops.3 sigemptyset.3 sigsetops.3 sigfillset.3 \
        sigsetops.3 sigaddset.3 sigsetops.3 sigdelset.3 \
        sigsetops.3 sigismember.3
diff -r 9d787dbd8c4f -r e8fdffaade8d lib/libc/gen/signalname.3
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/gen/signalname.3 Tue May 09 11:14:16 2017 +0000
@@ -0,0 +1,133 @@
+.\" $NetBSD: signalname.3,v 1.1 2017/05/09 11:14:16 kre Exp $
+.\"
+.\" Available to all and sundry, without restriction on use, or other
+.\" limitations, and without fee.   Also without any warranty of fitness
+.\" for any purpose whatever.
+.\"
+.\" Licensed for any use, including redistribution in source
+.\" and binary forms, with or without modifications, subject
+.\" the following agreement:
+.\"
+.\" Licensee agrees to indemnify licensor, and distributor, for
+.\" the full amount of any any claim made by the licensee against
+.\" the licensor or distributor, for any action that results from
+.\" any use or redistribution of this software, plus any costs
+.\" incurred by licensor or distributor resulting from that claim.
+.\"
+.\" This licence must be retained with the software.
+.\"
+.Dd April 28, 2017
+.Dt SIGNALNAME 3
+.Os
+.Sh NAME
+.Nm signalname
+.Nm signalnumber
+.Nm signalnext
+.Nd convert between signal numbers and names
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In signal.h
+.Ft const char *
+.Fn signalname "int sig"
+.Ft int
+.Fn signalnumber "const char *name"
+.Ft int
+.Fn signalnext "int sig"
+.Sh DESCRIPTION
+The
+.Fn signalname
+function takes a signal number
+.Fa sig ,
+and returns the name of that signal.
+The name returned is locale independent,
+and can be the string representation of one of the
+signal names from
+.In signal.h 
+such as SIGHUP, SIGSTOP, SIGKILL,
+or some similar name,
+but does not contain the leading
+.Dq SIG
+prefix.
+.Pp
+The return value of
+.Fn signalname
+is NULL if
+.Fa sig
+does not represent a valid signal number,
+or if the signal number given has no name.
+.Pp
+The
+.Fn signalnumber
+function converts the signal name
+.Fa name
+to the number corresponding to that signal.
+The
+.Fa name
+is handled in a case-insensitive manner.
+Any leading
+.Dq SIG
+prefix in
+.Fa name
+is ignored.
+.Pp
+The
+.Fn signalnumber
+function returns the signal number,
+or zero (0) if the name given does not represent a valid signal.
+.Pp
+The
+.Fn signalnext
+function takes a signal number, and returns the number of the
+next available bigger signal number.
+When no higher signal numbers remain, it returns zero (0).
+The parameter
+.Fa sig
+can be given as zero (0), to obtain the smallest implemented
+signal number.
+.Pp
+The
+.Fn signalnext
+function returns minus one (\-1) on error, if the given signal
+.Fa sig
+is neither a valid signal number, nor zero.
+It returns zero when the input signal number,
+.Fa sig ,
+is the biggest available signal number.
+Otherwise it returns the signal number of an implemented
+signal that is larger than
+.Fa sig
+and such that there are no implemented signals with values
+between
+.Fa sig
+and the value returned.
+.Pp
+The
+.Fn signalnext
+function can also be used to determine if a non-zero signal
+number is valid or not (0 is always invalid, but cannot be
+detected as such this way.)
+Given the non-zero signal number to check as
+.Fa sig ,
+if
+.Fn signalnext
+returns anything other than minus one (\-1)
+then
+.Fa sig
+represents a valid signal number.
+If the return value is \-1 then
+.Fa sig
+is invalid.
+.Sh SEE ALSO
+.Xr kill 1 ,
+.Xr intro 2 ,
+.Xr psignal 3 ,
+.Xr strsignal 3
+.Sh HISTORY
+The
+.Fn signalname ,
+.Fn signalnext
+and
+.Fn signalnumber
+functions first appeared in
+.Nx 8.0 .
diff -r 9d787dbd8c4f -r e8fdffaade8d lib/libc/gen/signalname.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/gen/signalname.c Tue May 09 11:14:16 2017 +0000
@@ -0,0 +1,44 @@
+/* $NetBSD: signalname.c,v 1.1 2017/05/09 11:14:16 kre Exp $ */
+
+/*
+ * Software available to all and sundry without limitations
+ * but without warranty of fitness for any purpose whatever.



Home | Main Index | Thread Index | Old Index