The problem with Emacs, at least, is in userland. POSIX says that closing
(including, implicitly, as a result of process termination) 'shall cause
any output to be sent to the device', but it does *not* impose an ordering
on the dispatch of SIGCHLD versus a read() of those bytes. So the SIGCHLD
can arrive at any time, including while you're reading data.
Since this can happen when you're reading any data from anywhere, it seems
unfortunate that Emacs isn't looping on -EINTR in read() everywhere.
(That part of the Unix API sucks rocks. SA_RESTART should have been the
default forever, IMNSHO. Instead, we *still* can't rely on it if we want
to be portable: two of the platforms I have to write code for don't
support it, so it's still -EINTR loops everywhere...)