[m-rev.] for review: Handle sem_wait, sem_timedwait being interrupted by signal handlers.
Julien Fischer
jfischer at opturion.com
Mon Jul 10 09:00:25 AEST 2017
Hi Peter,
On Wed, 5 Jul 2017, Peter Wang wrote:
> sem_wait or sem_timedwait may be interrupted by signal handlers and
> return an error. We must retry the call if errno is set to EINTR.
>
> library/thread.m:
> Retry MR_SEM_WAIT if interrupted by a signal handler in
> ML_create_exclusive_thread.
>
> Call MR_fatal_error if MR_SEM_WAIT fails for any other reason.
> The only other documented error code is EINVAL if the semaphore is
> invalid; that should not happen.
>
> runtime/mercury_context.c:
> Retry MR_SEM_WAIT if interrupted by a signal handler in
> MR_shutdown_ws_engines.
>
> runtime/mercury_thread.h:
> Add the macro MR_SEM_IS_EINTR for checking if errno == EINTR
> after calling MR_SEM_WAIT or MR_SEM_TIMED_WAIT.
That looks fine (apart from the issue you've already fixed).
Julien.
More information about the reviews
mailing list