From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 41225 invoked by alias); 7 Jul 2016 16:13:14 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 41162 invoked by uid 89); 7 Jul 2016 16:13:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1401 X-HELO: mail-wm0-f44.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=KewIK043mI+X1JjA4irWeVHXMC4KIP/44nRTM0k/srg=; b=J1SXpd2qc8Xnno8rV1z8Gdl7Wj9NFm+jYoXSlkV2ng2Tz6QRQvhWujf/xp5KmT74Do 7/9s2gMcuzxeBT7L7jrznnPokJc5HxISlRoZrlOOyWswI2evs1qU6X92BC+R324D48ic Qu8ZOSOseaJ7swj67DfDV6rKeVGcU7JOCG83McrpnPgAbTHpYIjcXoUe5y64xyz5i+hg /JD9MvoNWUJHZlHQKmpH26PQgdL8x7HI+J3PjbC3xGAxJ/tRGFjDOafVkkuzU0Mck4Fy f5EQT9aTl45qS/YEvTuRSVDYEKhTeZ9SO6eH1GFcfL9btUCqLEKGtHQYnLh3oUXHr1er Kqhw== X-Gm-Message-State: ALyK8tKz8wFV7PwtcdDF50sRajC1LsoxLaUJrBZR36XgLMx3zt/yZXUadaElB+P4azK4jZ9j X-Received: by 10.194.88.5 with SMTP id bc5mr1040851wjb.100.1467907980585; Thu, 07 Jul 2016 09:13:00 -0700 (PDT) Subject: Re: [PATCH] Refactor Linux raise implementation (BZ#15368) To: Andreas Schwab References: <1466188988-19954-1-git-send-email-adhemerval.zanella@linaro.org> <57658427.2090902@linaro.org> Cc: Zack Weinberg , GNU C Library From: Adhemerval Zanella Message-ID: <577E7F85.1050901@linaro.org> Date: Thu, 07 Jul 2016 16:13:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-SW-Source: 2016-07/txt/msg00201.txt.bz2 On 07/07/2016 12:30, Andreas Schwab wrote: > Adhemerval Zanella writes: > >> + /* raise is an async-safe function so it could be called while the >> + fork/vfork function temporarily invalidated the PID field. To avoid >> + relying in the cached value we block all user-defined signal handler >> + (which might call fork/vfork) and issues the getpid and gettid >> + directly. */ > > s/issues/issue/; s/^/ syscalls/ Right, I will fix it. > >> + sigset_t set; >> + __libc_signal_block_app (&set); >> + >> + INTERNAL_SYSCALL_DECL (err); >> + pid_t pid = INTERNAL_SYSCALL (getpid, err, 0); >> + pid_t tid = INTERNAL_SYSCALL (gettid, err, 0); >> + >> + int ret = INLINE_SYSCALL (tgkill, 3, pid, tid, sig); >> + >> + __libc_signal_restore_set (&set); > > What if block/unblock fail? My understanding checking on kernel source is 'rt_sigprocmask' may fail if: 1. sigsetsize != sizeof (sigset_t) (EINVAL) 2. a failure in copy_from_user/copy_to_user (EFAULT) 3. an invalid 'how' operation (EINVAL) The first case is already handle in glibc syscall call by using the arch defined _NSIG. Second is handled by using a stack allocated mask in 'raise' implementation. The last one should be handled by the __libc_signal_{un}block_{app,all} macros. I think there is no need in this specific usage to handle failures.