From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12546 Path: news.gmane.org!.POSTED!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] sigtimedwait: allow failing with EINTR Date: Sat, 24 Feb 2018 09:39:46 -0500 Message-ID: <20180224143946.GK1436@brightrain.aerifal.cx> References: <20180223214531.GJ1436@brightrain.aerifal.cx> <9DFC885B-7454-4F81-A2BF-AED124FF80AD@gmail.com> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1519483081 24432 195.159.176.226 (24 Feb 2018 14:38:01 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 24 Feb 2018 14:38:01 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-12562-gllmg-musl=m.gmane.org@lists.openwall.com Sat Feb 24 15:37:56 2018 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1epaxY-00064A-JH for gllmg-musl@m.gmane.org; Sat, 24 Feb 2018 15:37:56 +0100 Original-Received: (qmail 12263 invoked by uid 550); 24 Feb 2018 14:39:59 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 12243 invoked from network); 24 Feb 2018 14:39:59 -0000 Content-Disposition: inline In-Reply-To: <9DFC885B-7454-4F81-A2BF-AED124FF80AD@gmail.com> Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:12546 Archived-At: On Sat, Feb 24, 2018 at 11:45:16AM +0100, Julien Ramseier wrote: > > > > Le 23 févr. 2018 à 22:45, Rich Felker a écrit : > > > > On Fri, Feb 23, 2018 at 01:09:35PM +0100, Julien Ramseier wrote: > >> According to POSIX, sigtimedwait(2) is allowed to fail > >> with EINTR, while sigwait(3) is not, so move the retry loop there. > >> --- > > > > This is a "may fail", not a "shall fail". Generally we prefer not to > > support EINTR in cases where it's optional, since getting rid of them > > with retry loops makes it safe to run on old kernels or > > pseudo-linux-compat systems where SA_RESTART semantics were/are not > > actually conforming. Is there a reason you want it to fail with EINTR? > > > > Rich > > Some apps seem to rely on this, notably Python where a test case expects > sigtimedwait to be interrupted when a SIGALRM is fired. > > I cannot find another case in musl where EINTR is inhibited > (while being allowed by POSIX), are there any? sem_wait (via sem_timedwait). This is a case where I know the kernel bug (SYS_futex returning EINTR when it shouldn't) wasn't fixed until relatively late, and it's particularly dangerous because callers of sem_wait generally don't expect to return without having obtained the semaphore, and might not even be checking for errors (since there are no reasonable errors that could happen unless you installed interrupting signal handlers). Note that the timed variant always has a reasonable error you have to check for (ETIMEDOUT) so it may make sense to move the retry there. In the case of sem_timedwait there may be other implementation considerations that make it difficult though; I remember something came up discussing Alexander Monakov's ideas for new semaphore design. Analogous behavior might be appropriate here (but see also sigwaitinfo which is the non-timed version of sigtimedwait; sigwait is just the legacy version). Rich