<div dir="ltr"><br><br><div class="gmail_quote">On Sun Feb 08 2015 at 12:21:36 AM Victor Stinner <<a href="mailto:victor.stinner@gmail.com">victor.stinner@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr"><br>
Le 8 févr. 2015 05:39, "Gregory P. Smith" <<a href="mailto:greg@krypto.org" target="_blank">greg@krypto.org</a>> a écrit :<br>
> From there, in your signal handler you must try to acquire the newly exposed keymutex and (...)</p>
<p dir="ltr">Stop! Acquiring a lock in a signal handler is just a crazy idea. It's very far from an async signal-safe function.</p></blockquote><div>I'd normally agree... In this case, sem_trywait() is non-blocking. It is unfortunately not on the official POSIX list of async-signal-safe functions (of the SEMs, only sem_post() is) but many implementations actually are safe, documented or not.</div><div><br></div><div><a href="https://github.com/lattera/glibc/blob/master/nptl/sysdeps/unix/sysv/linux/x86_64/sem_trywait.S">https://github.com/lattera/glibc/blob/master/nptl/sysdeps/unix/sysv/linux/x86_64/sem_trywait.S</a> - appears safe.</div><div><span style="font-size:14.8500003814697px"><br></span></div><div><span style="font-size:14.8500003814697px">So long as the underlying semaphore is implemented using an atomic instruction on the target platform I wouldn't expect any implementation of sem_trywait to be async signal unsafe. (nor would I depend on that without checking)</span></div><div><span style="font-size:14.8500003814697px"><br></span></div><div><span style="font-size:14.8500003814697px">-gps</span></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<p dir="ltr">> So until those are fixed (hooray for Antoine's PEP!), ...</p>
<p dir="ltr">I wrote the PEP with Charles François Natali, but Charles wrote the whole implementation. Antoine also helped us and approved the PEP. It's the french connection! Just to say that Charles did most of the work.</p>
<p dir="ltr">Victor</p>
</blockquote></div></div>