Patch from Thomas. See id:87twzoxd3b.fsf@kepler.schwinge.homeip.net. This shows, for the expect script: 2946: /dev/ptyp1: starting PTY 2946: /dev/ptyp1: tf 2 qs(oq) 7461 2946: /dev/ptyp1: pm 0 uim 0 cb 0 2946: /dev/ptyp1: tf 2 qs(oq) 3365 2946: /dev/ptyp1: pm 0 uim 0 cb 0 2946: /dev/ptyp1: tf 0 qs(oq) 0 2946: /dev/ptyp1: pm 0 uim 0 cb 0 ..., and for a screen window exit: 2970: /dev/ptyp2: tf 2 qs(oq) 6 2970: /dev/ptyp2: pm 1 uim 0 cb 0 2970: /dev/ptyp2: tf 0 qs(oq) 0 2970: /dev/ptyp2: pm 1 uim 0 cb 1 In both cases, the last iteration (starting with "tf") is the problematic one. The size of the output queue is zero in both cases, which is why Samuel's patch doesn't make a difference. The expect script case is different from the screen window exit one in that the latter is running in packet mode. So here is my patch -- with no rationale by citing any standards, or similar. Any comments on that already? (I don't feel like committing such a change without understanding it.) --- a/term/ptyio.c +++ b/term/ptyio.c @@ -331,7 +331,7 @@ pty_io_read (struct trivfs_protid *cred, } } - if (!(termflags & TTY_OPEN) && !qsize (outputq)) + if (!(termflags & TTY_OPEN) && packet_mode) { pthread_mutex_unlock (&global_lock); return EIO;