From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: from second.openwall.net (second.openwall.net [193.110.157.125]) by inbox.vuxu.org (Postfix) with SMTP id 3EB1D21133 for ; Wed, 26 Jun 2024 17:31:00 +0200 (CEST) Received: (qmail 21979 invoked by uid 550); 26 Jun 2024 15:30:55 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 21944 invoked from network); 26 Jun 2024 15:30:55 -0000 Date: Wed, 26 Jun 2024 11:30:46 -0400 From: Rich Felker To: =?utf-8?B?5LuH546J5Yqg?= <1066414879@qq.com> Cc: musl Message-ID: <20240626153045.GM10433@brightrain.aerifal.cx> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] The sigtimedwait function can't return EINTR On Tue, Jun 25, 2024 at 02:14:29PM +0800, ไป‡็Ž‰ๅŠ  wrote: > Hi, > > > Why not check for EINTR errors in sigwait function instead of sigtimedwait function? > In posix, the sigtimedwait function can return an EINTR error. It's a may fail, not a shall fail, so either behavior is allowed. > Can you give me a reason for this situation? Commit 0a949ebdf0b9fc054ea868bd049c8f2c7aed973e documents that it was necessary that sigwait not fail with EINTR, so the logic to retry in EINTR had to be added either in sigwait or sigtimedwait. Generally we don't utilize "may fail" unless there's a good reason. In the case of sigtimedwait, I think my reasoning was that it's already waiting for one of a set of signals, and you could just include the signal(s) you want to be interrupted by in that set. Since the EINTR condition is not mandatory, this is the only portable way to do it. Rich