Merge pull request #105 from zagor/show-error

Show error when failing to open a tty
This commit is contained in:
Martin Lund 2021-01-18 01:16:41 +01:00 committed by GitHub
commit a4da50dbd8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -518,6 +518,7 @@ void tty_wait_for_device(void)
struct timeval tv;
static char input_char, previous_char = 0;
static bool first = true;
static int last_errno = 0;
/* Loop until device pops up */
while (true)
@ -564,8 +565,15 @@ void tty_wait_for_device(void)
}
/* Test for accessible device file */
if (access(option.tty_device, R_OK) == 0)
int rc = access(option.tty_device, R_OK);
if (rc == 0) {
last_errno = 0;
return;
}
else if (last_errno != errno) {
tio_printf("%s: %s. Waiting...", option.tty_device, strerror(errno));
last_errno = errno;
}
}
}