mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
Fix write in non-interactive piping mode
So that piping does not break when write buffer is full because e.g. device has flow control enabled and can't keep up.
This commit is contained in:
parent
f887756a71
commit
d1328e694e
1 changed files with 13 additions and 0 deletions
13
src/tty.c
13
src/tty.c
|
|
@ -2641,6 +2641,19 @@ int tty_connect(void)
|
||||||
/* If stdin is a pipe forward all input to tty device */
|
/* If stdin is a pipe forward all input to tty device */
|
||||||
if (interactive_mode == false)
|
if (interactive_mode == false)
|
||||||
{
|
{
|
||||||
|
// Set blocking mode for serial device (blocking write)
|
||||||
|
int flags = fcntl(device_fd, F_GETFL, 0);
|
||||||
|
if (flags == -1)
|
||||||
|
{
|
||||||
|
tio_error_printf("Could not read descriptor flags (%s)", strerror(errno));
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
if (fcntl(device_fd, F_SETFL, flags & ~O_NONBLOCK) == -1)
|
||||||
|
{
|
||||||
|
tio_error_printf("Could not set descriptor flags (%s)", strerror(errno));
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
int ret = read(pipefd[0], &input_char, 1);
|
int ret = read(pipefd[0], &input_char, 1);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue