When sterm is run with pipe as stdin rather than terminal, as is the
case, for example, with the following command:
ssh somewhere sterm /dev/ttyS0
closing the pipe (e.g. killing ssh) does not send SIGHUP signal, but
POLLHUP event is reported by poll(). When this happened, sterm ended
up in an infinite loop, consuming 100% CPU. Now, we handle this event
and exit.
/*
* Simple serial terminal
*
- * Copyright 2014, 2015, 2016, 2017 Michal Sojka <sojkam1@fel.cvut.cz>
+ * Copyright 2014, 2015, 2016, 2017, 2019 Michal Sojka <sojkam1@fel.cvut.cz>
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
exit(1);
}
}
+ if (fds[0].revents & POLLHUP) {
+ VERBOSE("HUP on stdin\r\n");
+ break;
+ }
if (fds[1].revents & POLLIN) {
r1 = CHECK(read(fd, buf, sizeof(buf)));
if (r1 == 0) {