Skip to content

Commit

Permalink
[kernel,cmds] Fix tty SIGINT not handled when using sercat
Browse files Browse the repository at this point in the history
  • Loading branch information
ghaerr committed Sep 5, 2024
1 parent a4f544f commit 01c5ad6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
2 changes: 2 additions & 0 deletions elks/arch/i86/drivers/char/ntty.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,8 @@ size_t tty_read(struct inode *inode, struct file *file, char *data, size_t len)
break;
ch = chq_wait_rd(&tty->inq, nonblock);
if (ch < 0) {
if (current->signal)
return -EINTR;
if (!icanon && vtime) {
if (jiffies < timeout) {
schedule();
Expand Down
20 changes: 17 additions & 3 deletions elkscmd/sys_utils/sercat.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,31 @@ void copyfile(int ifd, int ofd)

int main(int argc, char **argv)
{
char *port = NULL;
char *tty;

if (argc > 1 && !strcmp(argv[1], "-v")) {
verbose = 1;
argc--;
argv++;
}
if (argc > 1) {
if ((fd = open(argv[1], O_RDONLY|O_EXCL)) < 0) {
perror(argv[1]);
if (argc > 1)
port = argv[1];
else {
/* default to /dev/ttyS0 if not run from serial port and no argument */
if (strncmp(ttyname(STDIN_FILENO), "/dev/ttyS", 9) != 0)
port = "/dev/ttyS0";
}
if (port) {
if ((fd = open(port, O_RDONLY|O_EXCL)) < 0) {
perror(port);
return 1;
}
} else fd = STDIN_FILENO;
tty = ttyname(fd);
errmsg("Reading from ");
errstr(tty);
errmsg("\n");

if (tcgetattr(fd, &org) >= 0) {
new = org;
Expand Down

0 comments on commit 01c5ad6

Please sign in to comment.