From patchwork Thu May 14 19:26:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 39248 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 94DE6395CCB4; Thu, 14 May 2020 19:26:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 94DE6395CCB4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1589484403; bh=YFTSD+kOvMv2ga67UdIz6tYnc++8MIJ6y4qLFthTVeU=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ERWChofpGHAIvJAVvPdAGmbTjFU9mk5bunm04gGBRRcM2fjAxsTM+0nfOe01VYlgI 0nHtnu4ANT5zZb4VqyGdg14XVa7OklAJTMNcd61QhF+uvV6jpbaZFP7P17ERVUxVaX 29yMdU+Sbsr04MXAbrdr+fWHwIDjIKwIoO8B9DN8= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by sourceware.org (Postfix) with ESMTP id 8DFCE38708D8 for ; Thu, 14 May 2020 19:26:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8DFCE38708D8 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-245-17BKGqYsMtaczvVEDYmj7w-1; Thu, 14 May 2020 15:26:37 -0400 X-MC-Unique: 17BKGqYsMtaczvVEDYmj7w-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 840E28018A5 for ; Thu, 14 May 2020 19:26:36 +0000 (UTC) Received: from oldenburg2.str.redhat.com (ovpn-113-174.ams2.redhat.com [10.36.113.174]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A87AB7D951 for ; Thu, 14 May 2020 19:26:35 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH v2] signal: Deprecate additional legacy signal handling functions Date: Thu, 14 May 2020 21:26:34 +0200 Message-ID: <87pnb6qpw5.fsf@oldenburg2.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Florian Weimer via Libc-alpha From: Florian Weimer Reply-To: Florian Weimer Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" This needs a few test adjustments: In some cases, sigignore was used for convenience (replaced with xsignal with SIG_IGN). Tests for the deprecated functions need to disable -Wdeprecated-declarations, and for the sigmask deprecation, -Wno-error. Reviewed-by: Adhemerval Zanella --- Changes since v1: Use Deprecate siginterrupt, sigmask Mention alternative functions in the manual NEWS | 5 +++++ manual/signal.texi | 6 ++++++ nptl/Makefile | 7 +++++++ nptl/tst-cancel4.c | 7 +++++++ nptl/tst-exec1.c | 7 ++----- nptl/tst-exec2.c | 7 ++----- nptl/tst-exec3.c | 7 ++----- nptl/tst-exec4.c | 8 ++------ nptl/tst-exec5.c | 6 +----- signal/signal.h | 23 ++++++++++++++++------- signal/tst-sigset2.c | 4 ++++ signal/tst-sigsimple.c | 3 +++ 12 files changed, 57 insertions(+), 33 deletions(-) diff --git a/NEWS b/NEWS index 141078c319..fb46af2dd3 100644 --- a/NEWS +++ b/NEWS @@ -35,6 +35,11 @@ Deprecated and removed features, and other changes affecting compatibility: Its implementation always returned with a failure, and the function was not declared in any header file. +* The legacy signal handling functions siginterrupt, sigpause, sighold, + sigrelse, sigignore and sigset, and the sigmask macro have been + deprecated. Applications should use the sigsuspend, sigprocmask and + sigaction functions instead. + Changes to build and runtime requirements: * powerpc64le requires GCC 7.4 or newer. This is required for supporting diff --git a/manual/signal.texi b/manual/signal.texi index 33e6646975..911b422a18 100644 --- a/manual/signal.texi +++ b/manual/signal.texi @@ -3250,6 +3250,9 @@ are interrupted by handling signal @var{signum}. If @var{failflag} is false, signal @var{signum} restarts primitives. If @var{failflag} is true, handling @var{signum} causes these primitives to fail with error code @code{EINTR}. @xref{Interrupted Primitives}. + +This function has been replaced by the @code{SA_RESTART} flag of the +@code{sigaction} function. @xref{Advanced Signal Handling}. @end deftypefun @deftypefn Macro int sigmask (int @var{signum}) @@ -3267,6 +3270,9 @@ together to specify more than one signal. For example, @noindent specifies a mask that includes all the job-control stop signals. + +This macro has been replaced by the @code{sigset_t} type and the +associated signal set manipulation functions. @xref{Signal Sets}. @end deftypefn @deftypefun int sigblock (int @var{mask}) diff --git a/nptl/Makefile b/nptl/Makefile index ef9a6eb561..105ae50301 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -501,6 +501,13 @@ endif # function frequently to get a thread-specific handle. CFLAGS-pthread_self.os += -fomit-frame-pointer +# The sigmask macro is deprecated and triggers are compiler warning +# which cannot be suppressed (as of GCC 9). +CFLAGS-tst-cancel4.c += -Wno-error +CFLAGS-tst-cancel5.c += -Wno-error +CFLAGS-tst-cancelx4.c += -Wno-error +CFLAGS-tst-cancelx5.c += -Wno-error + # Run the cancellation and cleanup tests also for the modern, exception-based # implementation. For this we have to pass the -fexceptions parameter. CFLAGS-tst-cancelx2.c += -fexceptions diff --git a/nptl/tst-cancel4.c b/nptl/tst-cancel4.c index 652668537a..be7a48e253 100644 --- a/nptl/tst-cancel4.c +++ b/nptl/tst-cancel4.c @@ -39,6 +39,7 @@ #include #include #include +#include /* Since STREAMS are not supported in the standard Linux kernel and @@ -527,7 +528,13 @@ tf_sigpause (void *arg) pthread_cleanup_push (cl, NULL); + /* This tests the deprecated sigpause and sigmask functions. The + file is compiled with -Wno-errno so that the sigmask deprecation + warning is not fatal. */ + DIAG_PUSH_NEEDS_COMMENT; + DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wdeprecated-declarations"); sigpause (sigmask (SIGINT)); + DIAG_POP_NEEDS_COMMENT; pthread_cleanup_pop (0); diff --git a/nptl/tst-exec1.c b/nptl/tst-exec1.c index e1a5baa41f..892107d4c7 100644 --- a/nptl/tst-exec1.c +++ b/nptl/tst-exec1.c @@ -27,6 +27,7 @@ #include #include #include +#include static void * @@ -56,11 +57,7 @@ do_test (void) } /* Not interested in knowing when the pipe is closed. */ - if (sigignore (SIGPIPE) != 0) - { - puts ("sigignore failed"); - exit (1); - } + xsignal (SIGPIPE, SIG_IGN); posix_spawn_file_actions_t a; if (posix_spawn_file_actions_init (&a) != 0) diff --git a/nptl/tst-exec2.c b/nptl/tst-exec2.c index 3d3fb430bf..f57903da1e 100644 --- a/nptl/tst-exec2.c +++ b/nptl/tst-exec2.c @@ -27,6 +27,7 @@ #include #include #include +#include static void * @@ -56,11 +57,7 @@ do_test (void) } /* Not interested in knowing when the pipe is closed. */ - if (sigignore (SIGPIPE) != 0) - { - puts ("sigignore failed"); - exit (1); - } + xsignal (SIGPIPE, SIG_IGN); pid_t pid = fork (); if (pid == -1) diff --git a/nptl/tst-exec3.c b/nptl/tst-exec3.c index 8a018e916e..b849d3aef7 100644 --- a/nptl/tst-exec3.c +++ b/nptl/tst-exec3.c @@ -27,6 +27,7 @@ #include #include #include +#include static void * @@ -50,11 +51,7 @@ do_test (void) } /* Not interested in knowing when the pipe is closed. */ - if (sigignore (SIGPIPE) != 0) - { - puts ("sigignore failed"); - exit (1); - } + xsignal (SIGPIPE, SIG_IGN); pid_t pid = fork (); if (pid == -1) diff --git a/nptl/tst-exec4.c b/nptl/tst-exec4.c index cf5998219b..2f32389f41 100644 --- a/nptl/tst-exec4.c +++ b/nptl/tst-exec4.c @@ -22,17 +22,13 @@ #include #include #include - +#include static void * tf (void *arg) { /* Ignore SIGUSR1 and block SIGUSR2. */ - if (sigignore (SIGUSR1) != 0) - { - puts ("sigignore failed"); - exit (1); - } + xsignal (SIGUSR1, SIG_IGN); sigset_t ss; sigemptyset (&ss); diff --git a/nptl/tst-exec5.c b/nptl/tst-exec5.c index 02628931c8..c77f856263 100644 --- a/nptl/tst-exec5.c +++ b/nptl/tst-exec5.c @@ -86,11 +86,7 @@ do_test (void) } /* Not interested in knowing when the pipe is closed. */ - if (sigignore (SIGPIPE) != 0) - { - puts ("error: sigignore failed"); - exit (1); - } + xsignal (SIGPIPE, SIG_IGN); /* To synchronize with the thread. */ if (pthread_barrier_init (&b, NULL, 2) != 0) diff --git a/signal/signal.h b/signal/signal.h index 40825e95ec..2c57f90e20 100644 --- a/signal/signal.h +++ b/signal/signal.h @@ -148,7 +148,8 @@ extern void psiginfo (const siginfo_t *__pinfo, const char *__s); #ifdef __USE_XOPEN_EXTENDED # ifdef __GNUC__ -extern int sigpause (int __sig) __asm__ ("__xpg_sigpause"); +extern int sigpause (int __sig) __asm__ ("__xpg_sigpause") + __attribute_deprecated_msg__ ("Use the sigsuspend function instead"); # else extern int __sigpause (int __sig_or_mask, int __is_sig); /* Remove a signal from the signal mask and suspend the process. */ @@ -164,7 +165,9 @@ extern int __sigpause (int __sig_or_mask, int __is_sig); simply do not work in many situations. Use `sigprocmask' instead. */ /* Compute mask for signal SIG. */ -# define sigmask(sig) ((int)(1u << ((sig) - 1))) +# define sigmask(sig) \ + __glibc_macro_warning ("sigmask is deprecated") \ + ((int)(1u << ((sig) - 1))) /* Block signals in MASK, returning the old mask. */ extern int sigblock (int __mask) __THROW __attribute_deprecated__; @@ -311,7 +314,8 @@ extern int sigreturn (struct sigcontext *__scp) __THROW; /* If INTERRUPT is nonzero, make signal SIG interrupt system calls (causing them to fail with EINTR); if INTERRUPT is zero, make system calls be restarted after signal SIG. */ -extern int siginterrupt (int __sig, int __interrupt) __THROW; +extern int siginterrupt (int __sig, int __interrupt) __THROW + __attribute_deprecated_msg__ ("Use sigaction with SA_RESTART instead"); # include # include @@ -340,16 +344,21 @@ extern int sigstack (struct sigstack *__ss, struct sigstack *__oss) /* Simplified interface for signal management. */ /* Add SIG to the calling process' signal mask. */ -extern int sighold (int __sig) __THROW; +extern int sighold (int __sig) __THROW + __attribute_deprecated_msg__ ("Use the sigprocmask function instead"); /* Remove SIG from the calling process' signal mask. */ -extern int sigrelse (int __sig) __THROW; +extern int sigrelse (int __sig) __THROW + __attribute_deprecated_msg__ ("Use the sigprocmask function instead"); /* Set the disposition of SIG to SIG_IGN. */ -extern int sigignore (int __sig) __THROW; +extern int sigignore (int __sig) __THROW + __attribute_deprecated_msg__ ("Use the signal function instead"); /* Set the disposition of SIG. */ -extern __sighandler_t sigset (int __sig, __sighandler_t __disp) __THROW; +extern __sighandler_t sigset (int __sig, __sighandler_t __disp) __THROW + __attribute_deprecated_msg__ + ("Use the signal and sigprocmask functions instead"); #endif #if defined __USE_POSIX199506 || defined __USE_UNIX98 diff --git a/signal/tst-sigset2.c b/signal/tst-sigset2.c index f653323321..4eef653f95 100644 --- a/signal/tst-sigset2.c +++ b/signal/tst-sigset2.c @@ -9,6 +9,10 @@ #include #include #include +#include + +/* The sigset function is deprecated. */ +DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wdeprecated-declarations"); #define TEST_SIG SIGINT diff --git a/signal/tst-sigsimple.c b/signal/tst-sigsimple.c index d0e6b2f340..56202348bc 100644 --- a/signal/tst-sigsimple.c +++ b/signal/tst-sigsimple.c @@ -20,7 +20,10 @@ #include #include #include +#include +/* The sighold and sigrelse functions are deprecated. */ +DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wdeprecated-declarations"); static int do_test (void)