Do not return false read error when piping to tio

This commit is contained in:
Martin Lund 2022-07-20 13:11:11 +02:00
parent 40c8753151
commit a0a8dccd51

View file

@ -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<bytes_read; i++)