diff options
author | Alexey Gladkov <gladkov.alexey@gmail.com> | 2023-05-22 16:40:49 +0200 |
---|---|---|
committer | Alexey Gladkov <gladkov.alexey@gmail.com> | 2023-05-22 16:40:49 +0200 |
commit | e32f2cbafcc4f5888878e09de43b17f9cd16fce9 (patch) | |
tree | 78d7fbf0bfbf5e33d3fa5ca3fcc436a8475c5457 | |
parent | 95cf4cd63babeb5f90a004fa37543fe40c7b5cbf (diff) | |
download | kbd-e32f2cbafcc4f5888878e09de43b17f9cd16fce9.tar.gz |
Show only one error message if the terminal is lost
If the user has asked via system call for the terminal to be hung up
(TIOCVHANGUP) in the process of executing loadkeys, then subsequent
ioctls that loadkeys executes will fail with an EIO error [1][2].
Since any further ioctls will return an EIO error, dozens of error
messages will be generated.
If we get an EIO error then there is no need to try to continue since we
no longer have a valid descriptor.
[1] https://github.com/torvalds/linux/blob/44c026a73be8038f03dbdeef028b642880cf1511/drivers/tty/tty_io.c#L2783
[2] https://github.com/torvalds/linux/blob/44c026a73be8038f03dbdeef028b642880cf1511/drivers/tty/tty_ldisc.c#L223
Link: https://github.com/legionus/kbd/issues/92
Signed-off-by: Alexey Gladkov <gladkov.alexey@gmail.com>
-rw-r--r-- | src/libkeymap/loadkeys.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libkeymap/loadkeys.c b/src/libkeymap/loadkeys.c index 4e663921..bd23d006 100644 --- a/src/libkeymap/loadkeys.c +++ b/src/libkeymap/loadkeys.c @@ -57,6 +57,15 @@ defkeys(struct lk_ctx *ctx, int fd, int kbd_mode) j = NR_KEYS; continue; } + if (errno == EIO) { + /* + * Such an error can be returned + * if the tty has been hungup + * while loadkeys is running. + */ + ERR(ctx, "%s", strerror(errno)); + goto fail; + } ERR(ctx, "%s", strerror(errno)); } else ct++; |