This enables us to properly grab the @sigchld_mutex and synchronize
with writers.
It turns out that signal handlers execute on the main thread and may
interleave with other writers. This manifested as handle_sigchldwriteing to pipes that had already been closed (by the IO.pipe)
block, resulting in nasty exceptions.
By grabbing the lock, we ensure that we serialize reading the list of
wakeup pipes properly with respect to writers. The signal handler now
exists only to signal that thread, and is defensively coded against
running at random moments in time.
This enables us to properly grab the
@sigchld_mutex
and synchronize with writers.It turns out that signal handlers execute on the main thread and may interleave with other writers. This manifested as
handle_sigchld
write
ing to pipes that had already been closed (by theIO.pipe
) block, resulting in nasty exceptions.By grabbing the lock, we ensure that we serialize reading the list of wakeup pipes properly with respect to writers. The signal handler now exists only to signal that thread, and is defensively coded against running at random moments in time.
r? @andrew-stripe cc @stripe/product-infra