ICS-664: Fix "cu problem"

In ttynvt_read(), the "interrupted" signal may be delivered after
installing the handler (fuse_req_interrupt_func()) but before calling
read().
If this happens the signal intended to be delivered while in the read()
function call (SIGUSR2) is handled before the read(), and we may hang
indefinitely.
This commit is contained in:
Kim Woelders
2018-10-04 09:23:14 +02:00
parent bf21ada8c7
commit 1ded3b11d2
+6 -1
View File
@@ -99,9 +99,12 @@ _PRF2_ static void _log(int prio, const char *fmt, ...)
#define DBG2(...) \
if (ttynvt_param.debug > 1) _log(LOG_DEBUG, __VA_ARGS__)
static volatile char _is_interrupted = 0;
static void sig_handler(int sig)
{
DBG("Interruped, signal = %d\n", sig);
_is_interrupted = 1;
}
static void set_signal_handler(void)
@@ -489,7 +492,9 @@ ttynvt_read(fuse_req_t req, size_t size, off_t off,
size = TMP_BUF_SIZE;
fuse_req_interrupt_func(req, ttynvt_interrupted, (void *)pthread_self());
res = read(tty->fds[FD_SLAVE].fd, tty->tmp_buf, size);
res =
_is_interrupted ? -2 : read(tty->fds[FD_SLAVE].fd, tty->tmp_buf, size);
_is_interrupted = 0;
fuse_req_interrupt_func(req, NULL, NULL);
if (res < 0)
{