diff --git a/src/tty.c b/src/tty.c index a96c50d..7464d1b 100644 --- a/src/tty.c +++ b/src/tty.c @@ -1153,11 +1153,16 @@ int tty_connect(void) { /* Input from stdin ready */ ssize_t bytes_read = read(STDIN_FILENO, input_buffer, BUFSIZ); - if (bytes_read <= 0) + if (bytes_read < 0) { - tio_error_printf_silent("Could not read from stdin"); + tio_error_printf_silent("Could not read from stdin (%s)", strerror(errno)); goto error_read; } + else if (bytes_read == 0) + { + // Reached EOF (when piping to stdin) + exit(EXIT_SUCCESS); + } /* Process input byte by byte */ for (int i=0; i