src/nnn.c | 20 ++++++++++++++++---- diff --git a/src/nnn.c b/src/nnn.c index 5c8934622c6f753115752b07b5aabe4c108e9a29..5bd7d6a6c218e5a1cd3bce0f6c34deb925d5a661 100644 --- a/src/nnn.c +++ b/src/nnn.c @@ -4300,11 +4300,20 @@ listpath = NULL; } } +static ssize_t read_nointr(int fd, void *buf, size_t count) +{ + ssize_t len; + do{ + len = read(fd, buf, count); + } while (len == -1 && errno == EINTR); + return len; +} + static void readpipe(int fd, char **path, char **lastname, char **lastdir) { int r; char ctx, *nextpath = NULL; - ssize_t len = read(fd, g_buf, 1); + ssize_t len = read_nointr(fd, g_buf, 1); if (len != 1) return; @@ -4317,14 +4326,14 @@ if (ctx < 0 || ctx > CTX_MAX) return; } - len = read(fd, g_buf, 1); + len = read_nointr(fd, g_buf, 1); if (len != 1) return; char op = g_buf[0]; if (op == 'c') { - len = read(fd, g_buf, PATH_MAX); + len = read_nointr(fd, g_buf, PATH_MAX); if (len <= 0) return; @@ -4415,7 +4424,10 @@ close(wfd); _exit(EXIT_SUCCESS); } - int rfd = open(g_pipepath, O_RDONLY); + int rfd; + do { + rfd = open(g_pipepath, O_RDONLY); + } while (rfd == -1 && errno == EINTR); readpipe(rfd, path, lastname, lastdir); close(rfd);