This code is quite useful, but both executePseudoTerminal and executePseudoTerminalFD blow up with “hardware fault (Input/output error)” when the child process exits and I try to read more of its output.

Is it possible to have child-exits just result in a EOF?
That way hGetContents won’t break.