From: "Joseph C. Sible" <josephcsible@gmail.com>
To: musl@lists.openwall.com
Subject: Re: Compile-time flag to enable optional EINTR's?
Date: Fri, 7 Sep 2018 00:09:33 -0400 [thread overview]
Message-ID: <CABpewhFEqn1H7hLxxp53beNwzeAPhsu6n-C9gJnThYcLkc4wcw@mail.gmail.com> (raw)
In-Reply-To: <20180907021657.GJ1878@brightrain.aerifal.cx>
> 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
next prev parent reply other threads:[~2018-09-07 4:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-07 1:26 Joseph C. Sible
2018-09-07 2:16 ` Rich Felker
2018-09-07 4:09 ` Joseph C. Sible [this message]
2018-09-07 13:15 ` Rich Felker
2018-09-07 13:57 ` Joseph C. Sible
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CABpewhFEqn1H7hLxxp53beNwzeAPhsu6n-C9gJnThYcLkc4wcw@mail.gmail.com \
--to=josephcsible@gmail.com \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).