I was just about to report that handling EINTR in File{In,Out}putProc doesn't eliminate the deadlock, it just pushes it out later (with a different stack trace, but this is whack-a-mole).

The interesting part of this trace seems to be:

#10 0x00007f4bba9a95cc in TclChannelEventScriptInvoker (clientData=0x2030f28, mask=2) at generic/tclIO.c:8866
#11 0x00007f4bba9a8e03 in Tcl_NotifyChannel (channel=0x2046e58, mask=2) at generic/tclIO.c:8360
#12 0x00007f4bba9a9003 in ChannelTimerProc (clientData=0x2046e58) at generic/tclIO.c:8526
#13 0x00007f4bba9f67aa in TimerHandlerEventProc (evPtr=0x1f93d68, flags=-3) at generic/tclTimer.c:593


> POSIX does not list pthread_mutex_(unlock|lock)() as async signal safe functions.

Can you give me a source?  I'd like to understand this better .. the Linux manual states:

> These functions shall not return an error code of [EINTR].

Feel free to ping me on chat for an email address to take this discussion off-ticket where we can be more verbose and tangential if you like :)