close.2: Note behavior when close() happens in a parallel thread
If one thread is blocked in an I/O system call on a file descriptor
that is closed in another thread, then the blocking system call
does not return immediately, but rather when the I/O operation
completes. This surprises some people, but is longstanding
behavior.
See https://bugzilla.kernel.org/show_bug.cgi?id=53781
and
https://lore.kernel.org/lkml/
3B1E3D86.
C7A7874@canal-plus.fr/
To: linux-kernel@vger.kernel.org
Subject: PROBLEM: I/O system call never returns if file desc is closed in the meantime
Date: Wed, 06 Jun 2001 16:26:14 +0200
Examples where people are surprised by this behavior:
https://www.linuxquestions.org/questions/linux-networking-3/recv-is-not-coming-out-of-blocking-after-closing-the-socket-459461/
https://stackoverflow.com/questions/
3589723/can-a-socket-be-closed-from-another-thread-when-a-send-recv-on-the-same-socket
Reported-by: Thierry Lelegard <thierry.lelegard@canal-plus.fr>
Reported-by: Lukas Czerner <lczerner@redhat.com>
Reported-by: Peter Schiffer <pschiffe@redhat.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>