From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.stackframe.dev (unknown [220.88.252.109]) by sourceware.org (Postfix) with ESMTPS id D0D3D385BF85 for ; Thu, 18 Nov 2021 18:35:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D0D3D385BF85 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=stackframe.dev Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=stackframe.dev Message-ID: <93244325-1846-1c14-d225-f69f2a5b76e6@stackframe.dev> Date: Fri, 19 Nov 2021 03:35:40 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.1 Subject: Re: Handles the masked signal when the thread exits Content-Language: en-US To: Florian Weimer Cc: libc-help@sourceware.org References: <2fb82128-a9da-e7f5-8062-f7e72b1561db@stackframe.dev> <8735ntfi9y.fsf@oldenburg.str.redhat.com> <7f3882b1-1c09-83af-40b9-979a400f097e@stackframe.dev> <87v90pe38f.fsf@oldenburg.str.redhat.com> <6ee2a107-c4da-eba7-64ed-8e06af7a961a@stackframe.dev> <87r1bde2o5.fsf@oldenburg.str.redhat.com> From: Gibeom Gwon In-Reply-To: <87r1bde2o5.fsf@oldenburg.str.redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, NICE_REPLY_A, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-help@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-help mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Nov 2021 18:35:45 -0000 On 11/19/21 03:31, Florian Weimer wrote: > * Gibeom Gwon: > >> On 11/19/21 03:19, Florian Weimer wrote: >>> * Gibeom Gwon: >>> >>>> On 11/19/21 03:08, Florian Weimer wrote: >>>>> * Gibeom Gwon: >>>>> >>>>>> I am experiencing strange(unintended?) behavior when using pthread >>>>>> with signals. If I set the signal mask with pthread_sigmask() in the >>>>>> thread function and the process has pending signal when thread is >>>>>> exiting, signal handler executed in thread. >>>>>> >>>>>> It looks like glibc restores original signal mask at the end of the >>>>>> thread. So I suspect this eventually triggers masked signal >>>>>> handler. But I'm not sure it is intended or not. >>>>> Which glibc version are you using? >>> >>>> Ah, I forgot to write the version. I'm using 2.33 and linux >>>> distribution is Arch Linux. >>> We had some issues with signals and thread exit in 2.34, but they >>> are >>> exclusive to that release and cannot happen in 2.33. I can't reproduce >>> the behavior you see with upstream 2.33, either. >>> What's your kernel version? I've tried 5.14.13 and 5.14.17. >>> Thanks, >>> Florian >>> >> >> Kernel version is 5.15.2. >> >> Well, I accidently dropped sleep.c code sample. Here are the code >> samples again. Sorry to bother you. > > Ah, now the test makes a little bit more sense. But I still get the > expected output: > > main thread: 140317152449984 > child thread: 140317150295616 > worker... > worker... > worker... > worker... > worker... > worker... > worker... > worker... > worker... > worker... > thread close > sigchld: 140317152449984 > > So the signal gets delivered on the main thread, as expected. > > Thanks, > Florian > I hit Ctrl+C in the middle of running signal program. You can see ^C and sigint:.. printed in my result. Regards, Gibeom Gwon