On read errors or EOF we close the pipe that corresponds to
stdout/stderr of the current display command. However, we miss to
reset the offset value of the command buffer in this case. If this
offset was positive at the time the read error occurred, we skip the
first part of the output of the next command.
Fix this by always resetting the offset after closing the pipe.
close(command_fds[i]);
command_fds[i] = -1;
flags[i] = 0;
+ cbo[i] = 0;
if (command_fds[!i] < 0) /* both fds closed */
return 0;
}