Eric Blake wrote: > I bet coreutils' sort has a similar bug [Adding bug-coreutils to the CC:.]
Coreutils 'sort' runs into this problem only if dup2 fails when called from move_fd_or_die or if execlp fails. dup2 should never fail when it's called the way that 'sort' calls it. So perhaps 'sort' should be simplified to call dup2 and discard its return value. And when execlp fails, 'sort' could _exit with a special value, so that the parent could report the failure.