From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/13204 Path: news.gmane.org!.POSTED!not-for-mail From: "Joseph C. Sible" Newsgroups: gmane.linux.lib.musl.general Subject: Re: Compile-time flag to enable optional EINTR's? Date: Fri, 7 Sep 2018 00:09:33 -0400 Message-ID: References: <20180907021657.GJ1878@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: blaine.gmane.org 1536293277 8324 195.159.176.226 (7 Sep 2018 04:07:57 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 7 Sep 2018 04:07:57 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-13220-gllmg-musl=m.gmane.org@lists.openwall.com Fri Sep 07 06:07:53 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 1fy83l-00025f-A5 for gllmg-musl@m.gmane.org; Fri, 07 Sep 2018 06:07:53 +0200 Original-Received: (qmail 28537 invoked by uid 550); 7 Sep 2018 04:10:00 -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 28516 invoked from network); 7 Sep 2018 04:09:59 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=qb5cYCQ5bmPvBrAcl4DTzP55HV5tpY8KF9mDHbNWEQM=; b=DqjXLeI57PuHrfGNepVphmbiIkw/lncXXRSU3i4fIxPv7bBN8N/9dueyPqR60UHsJH OQ5JnKOyFSRGBfhevpy+48DI8WIQmLAnr5IVRA8sxcj1l3VG9TY0xQce3L7Du3Pctu3u JGnu/1REg+52Q8AJPiVpvnIwcgXn/V0yWDS6t8croz2g5nT1Hnt+BwNWFm8NmhjwbNRM KQQonabdvVCmTr6gzZ+g/29dpXWiCwH01nLr4AMuJ75yCp7U3nuycHUfVOEKDiZ6XZ3B DGHY9yyq6w29f9mczInXPYNWApDGIwmMyJdbvSkinMwSyph2O7UjTctLc8rvbZycsgYf TzbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=qb5cYCQ5bmPvBrAcl4DTzP55HV5tpY8KF9mDHbNWEQM=; b=rUHEKoxMbGRnyoDZSV/oOpR8IfwcfNytbpDU3mJxKRi6QNQVvM/6KGuI+t2U8V6rlR p7sM+yHHR7920A3uwXl9FfxHaKW4P9sZ2dpY3YFlm1Q2Hd0qS1yjevVfaGA0UOfpk9ZM oovf4+W4qEIrL1ds54nLkQTIDST7RouSHFAiKcGzHJIYfah5QtWErf9VE1AmQ/1CHXxP jTQkg2LPWJeiPJptZ+3aL3lV2QLHPzxdLrlMIBF6FiBlN/pBsI8H/K73Gx+ZMtVLiRxQ LxKnLBiEb1fnoMn7whzXm+xcQo1NxNR7S/QIc+kACf8xZo/+emfN5NiIg+gcIOzzhHPK pOfw== X-Gm-Message-State: APzg51Bx4L4QRS6LI58tmPQ2FjLkgyxe6T7W9oNBJUsVpHj/XvOj90Jl idutdNQDnWp3FckwxtHfgqSORqgH9cCEA0wH0MumufGA X-Google-Smtp-Source: ANB0VdZeve2rZPvd4w3Lr/nvEWWarKamUrWgthbLu0LJrxXIDCqnc0NuYqIwdfpRd7cSKvk4n/qXY3ruJhIhBDxQU0c= X-Received: by 2002:a37:1216:: with SMTP id c22-v6mr4427202qkh.90.1536293387775; Thu, 06 Sep 2018 21:09:47 -0700 (PDT) In-Reply-To: <20180907021657.GJ1878@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:13204 Archived-At: > Can you discuss what you're trying to use EINTR for here? It's for a Python program with several threads that are often waiting on various locks, events, etc., all implemented by Python in terms of POSIX semaphores. If a thread is just waiting for work to do, and I trigger a graceful shutdown via a signal, I'd like it to give up waiting for work immediately rather than holding up shutdown until it times out doing nothing. > Most uses of > EINTR have fundamental race conditions -- if the signal arrives just > moments before the syscall you hoped to interrupt, it won't get > interrupted, and will block until some other event lets it proceed. I acknowledge the race condition. It's too bad there's no "p" variant of sem_timedwait(3) (thus of futex(2) as well) like there is of pselect vs. select. > If we did want to bring back EINTR for sem_[timed]wait, I think the > right thing to do would be to look for a workaround for the underlying > kernel bug, or some way to detect it and avoid honoring the EINTRs > that happen on old buggy kernels. One thing that was once suggested, > but I didn't really like it, was ignoring (retrying on) EINTR for > sem_wait, where the caller may not be prepared for it to return > without having decremented the semaphore value, but honoring it > (failing) for sem_timedwait, where the caller has to be prepared for > the possibility of failure (ETIMEDOUT) anyway. I didn't do much > research into whether this would be conforming but I think it would. Either one of these solutions sounds okay to me. I don't have any good ideas on how to do the former, though. Joseph C. Sible