From patchwork Thu Dec 18 05:55:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 422484 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 8A5D5140082 for ; Thu, 18 Dec 2014 16:55:25 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:references:date:in-reply-to :message-id:mime-version:content-type; q=dns; s=default; b=DTGwN a8u9iS1TYfKOrRjlHJCi07q5Kau8RI5cItDtgFc+F8Ak9445Fhiz0ddAe6grhOP6 bPUJ6lf0oXShvW7w5oI/vVMTpf5CGtyBdq64n1Htejqp+yxyR0Zsc1Uyf63qXLem hpkyoxuJHQlJV1Nhj6kfYBPlp81l8WQ0tZVlHY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:references:date:in-reply-to :message-id:mime-version:content-type; s=default; bh=YCYZN5pyROl x85OTDi3+PRFB85Q=; b=YvIr8Oua+MBlPXQV3V1l9rW7J50e1DX+fnfxlDtP/+w nm+35g05/+lcxKW4VnFTZ6C2wm5JI7o7gEms/huLP1TRzriEuuxQWysnPJbzUHMU sxTdDOgbcB2EEf6tEovjZvScz60gsvm8YW5dB44tfllN1cl1z1kIpqguIVvc0o9I = Received: (qmail 22569 invoked by alias); 18 Dec 2014 05:55:20 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 22554 invoked by uid 89); 18 Dec 2014 05:55:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.0 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com From: Alexandre Oliva To: MaShimiao Cc: libc-alpha@sourceware.org Subject: Re: question about which sleep is noted in manual References: <547ED48B.2060509@cn.fujitsu.com> <5487EAF0.70305@cn.fujitsu.com> Date: Thu, 18 Dec 2014 03:55:05 -0200 In-Reply-To: <5487EAF0.70305@cn.fujitsu.com> (MaShimiao's message of "Wed, 10 Dec 2014 14:40:48 +0800") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 [copying the list] On Dec 10, 2014, MaShimiao wrote: > But as I know, differen't thread has different signal mask. So, I have reviewed the sigprocmask notes, and I found out not only that the BSD implementation of signals was removed, so a number of the notes can go, but also that at least twice I failed to take into account the thread-local nature of signal masks. Big oops. Thanks for catching this. The patch below fixes all of these issues. Ok to install? for ChangeLog * manual/setjmp.texi (longjmp, sigsetjmp): Drop obsolete sigprocmask annotations. * manual/signal.texi (sigprocmask): Drop BSD-only race; the code is now gone, but the race was never there to begin with. (pause, sigsuspend, sigblock, sigpause): Adjust. --- manual/setjmp.texi | 4 ++-- manual/signal.texi | 48 ++++++++++++++++++------------------------------ 2 files changed, 20 insertions(+), 32 deletions(-) diff --git a/manual/setjmp.texi b/manual/setjmp.texi index ec79c26..a4722a3 100644 --- a/manual/setjmp.texi +++ b/manual/setjmp.texi @@ -132,7 +132,7 @@ execution state of the program in @var{state} and returns zero. If @c that calls longjmp may run the same cleanups multiple times. @c _JMPBUF_UNWINDS_ADJ ok @c *cleanup_buf->__routine @ascuplugin -@c sigprocmask(SIG_SETMASK) dup @asulock/hurd @aculock/hurd +@c sigprocmask dup @asulock/hurd @aculock/hurd @c __longjmp ok This function restores current execution to the state saved in @var{state}, and continues execution from the call to @code{setjmp} that @@ -221,7 +221,7 @@ information about the set of blocked signals. @c sigsetjmp @asulock/hurd @aculock/hurd @c __sigsetjmp(savemask) @asulock/hurd @aculock/hurd @c __sigjmp_save(savemask) @asulock/hurd @aculock/hurd -@c sigprocmask(SIG_BLOCK probe) dup @asulock/hurd @aculock/hurd +@c sigprocmask dup @asulock/hurd @aculock/hurd This is similar to @code{setjmp}. If @var{savesigs} is nonzero, the set of blocked signals is saved in @var{state} and will be restored if a @code{siglongjmp} is later performed with this @var{state}. diff --git a/manual/signal.texi b/manual/signal.texi index 77f3d7c..8f5ad98 100644 --- a/manual/signal.texi +++ b/manual/signal.texi @@ -2625,10 +2625,8 @@ Instead, use @code{pthread_sigmask}. @comment signal.h @comment POSIX.1 @deftypefun int sigprocmask (int @var{how}, const sigset_t *restrict @var{set}, sigset_t *restrict @var{oldset}) -@safety{@prelim{}@mtunsafe{@mtasurace{:sigprocmask/bsd(SIG_UNBLOCK)}}@asunsafe{@asulock{/hurd}}@acunsafe{@aculock{/hurd}}} -@c This takes the hurd_self_sigstate-returned object's lock on HURD. On -@c BSD, SIG_UNBLOCK is emulated with two sigblock calls, which -@c introduces a race window. +@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{/hurd}}@acunsafe{@aculock{/hurd}}} +@c This takes the hurd_self_sigstate-returned object's lock on HURD. The @code{sigprocmask} function is used to examine or change the calling process's signal mask. The @var{how} argument determines how the signal mask is changed, and must be one of the following values: @@ -2979,17 +2977,14 @@ you use it. @comment unistd.h @comment POSIX.1 @deftypefun int pause (void) -@safety{@prelim{}@mtunsafe{@mtasurace{:sigprocmask/!bsd!linux}}@asunsafe{@asulock{/hurd}}@acunsafe{@aculock{/hurd}}} -@c The signal mask read by sigprocmask may be overridden by another -@c thread or by a signal handler before we call sigsuspend. Is this a -@c safety issue? Probably not. -@c pause @mtasurace:sigprocmask/!bsd!linux @asulock/hurd @aculock/hurd +@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{/hurd}}@acunsafe{@aculock{/hurd}}} +@c pause @asulock/hurd @aculock/hurd @c [ports/linux/generic] @c syscall_pause ok @c [posix] @c sigemptyset dup ok -@c sigprocmask(SIG_BLOCK) dup @asulock/hurd @aculock/hurd [no @mtasurace:sigprocmask/bsd(SIG_UNBLOCK)] -@c sigsuspend dup @mtasurace:sigprocmask/!bsd!linux @asulock/hurd @aculock/hurd +@c sigprocmask dup @asulock/hurd @aculock/hurd +@c sigsuspend dup @asulock/hurd @aculock/hurd The @code{pause} function suspends program execution until a signal arrives whose action is either to execute a handler function, or to terminate the process. @@ -3085,16 +3080,11 @@ signals be handled by their handlers. @comment signal.h @comment POSIX.1 @deftypefun int sigsuspend (const sigset_t *@var{set}) -@safety{@prelim{}@mtunsafe{@mtasurace{:sigprocmask/!bsd!linux}}@asunsafe{@asulock{/hurd}}@acunsafe{@aculock{/hurd}}} -@c sigsuspend @mtasurace:sigprocmask/!bsd!linux @asulock/hurd @aculock/hurd -@c [posix] @mtasurace:sigprocmask/!bsd!linux -@c saving and restoring the procmask is racy -@c sigprocmask(SIG_SETMASK) dup @asulock/hurd @aculock/hurd [no @mtasurace:sigprocmask/bsd(SIG_UNBLOCK)] +@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{/hurd}}@acunsafe{@aculock{/hurd}}} +@c sigsuspend @asulock/hurd @aculock/hurd +@c [posix] +@c sigprocmask dup @asulock/hurd @aculock/hurd @c pause @asulock/hurd @aculock/hurd -@c [bsd] -@c sigismember dup ok -@c sigmask dup ok -@c sigpause dup ok [no @mtasurace:sigprocmask/!bsd!linux @asulock/hurd @aculock/hurd] @c [linux] @c do_sigsuspend ok This function replaces the process's signal mask with @var{set} and then @@ -3354,9 +3344,8 @@ specifies a mask that includes all the job-control stop signals. @deftypefun int sigblock (int @var{mask}) @safety{@prelim{}@mtsafe{}@asunsafe{@asulock{/hurd}}@acunsafe{@aculock{/hurd}}} @c On most POSIX systems, this is a wrapper for sigprocmask(SIG_BLOCK). -@c The exception are BSD systems other than 4.4, where it is a syscall. @c sigblock @asulock/hurd @aculock/hurd -@c sigprocmask(SIG_BLOCK) dup @asulock/hurd @aculock/hurd [no @mtasurace:sigprocmask/bsd(SIG_UNBLOCK)] +@c sigprocmask dup @asulock/hurd @aculock/hurd This function is equivalent to @code{sigprocmask} (@pxref{Process Signal Mask}) with a @var{how} argument of @code{SIG_BLOCK}: it adds the signals specified by @var{mask} to the calling process's set of blocked @@ -3368,9 +3357,8 @@ signals. The return value is the previous set of blocked signals. @deftypefun int sigsetmask (int @var{mask}) @safety{@prelim{}@mtsafe{}@asunsafe{@asulock{/hurd}}@acunsafe{@aculock{/hurd}}} @c On most POSIX systems, this is a wrapper for sigprocmask(SIG_SETMASK). -@c The exception are BSD systems other than 4.4, where it is a syscall. @c sigsetmask @asulock/hurd @aculock/hurd -@c sigprocmask(SIG_SETMASK) dup @asulock/hurd @aculock/hurd [no @mtasurace:sigprocmask/bsd(SIG_UNBLOCK)] +@c sigprocmask dup @asulock/hurd @aculock/hurd This function equivalent to @code{sigprocmask} (@pxref{Process Signal Mask}) with a @var{how} argument of @code{SIG_SETMASK}: it sets the calling process's signal mask to @var{mask}. The return value is @@ -3380,15 +3368,15 @@ the previous set of blocked signals. @comment signal.h @comment BSD @deftypefun int sigpause (int @var{mask}) -@safety{@prelim{}@mtunsafe{@mtasurace{:sigprocmask/!bsd!linux}}@asunsafe{@asulock{/hurd}}@acunsafe{@aculock{/hurd}}} -@c sigpause @mtasurace:sigprocmask/!bsd!linux @asulock/hurd @aculock/hurd +@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{/hurd}}@acunsafe{@aculock{/hurd}}} +@c sigpause @asulock/hurd @aculock/hurd @c [posix] -@c __sigpause @mtasurace:sigprocmask/!bsd!linux @asulock/hurd @aculock/hurd -@c do_sigpause @mtasurace:sigprocmask/!bsd!linux @asulock/hurd @aculock/hurd -@c sigprocmask(0) dup @asulock/hurd @aculock/hurd [no @mtasurace:sigprocmask/bsd(SIG_UNBLOCK)] +@c __sigpause @asulock/hurd @aculock/hurd +@c do_sigpause @asulock/hurd @aculock/hurd +@c sigprocmask dup @asulock/hurd @aculock/hurd @c sigdelset dup ok @c sigset_set_old_mask dup ok -@c sigsuspend dup @mtasurace:sigprocmask/!bsd!linux @asulock/hurd @aculock/hurd +@c sigsuspend dup @asulock/hurd @aculock/hurd This function is the equivalent of @code{sigsuspend} (@pxref{Waiting for a Signal}): it sets the calling process's signal mask to @var{mask}, and waits for a signal to arrive. On return the previous set of blocked