diff --git a/src/lib/fd.c b/src/lib/fd.c index 93ad66bbb..04c9caea0 100644 --- a/src/lib/fd.c +++ b/src/lib/fd.c @@ -79,8 +79,7 @@ ncfdplane_thread(void* vncfp){ return NULL; } -static int -set_fd_nonblocking(int fd){ +int set_fd_nonblocking(int fd){ int flags = fcntl(fd, F_GETFL, 0); if(flags < 0){ return -1; diff --git a/src/lib/internal.h b/src/lib/internal.h index 1817f09b9..22e641b66 100644 --- a/src/lib/internal.h +++ b/src/lib/internal.h @@ -1152,6 +1152,8 @@ int ncinputlayer_init(ncinputlayer* nilayer, FILE* infp); // FIXME absorb into ncinputlayer_init() int cbreak_mode(int ttyfd, const struct termios* tpreserved); +int set_fd_nonblocking(int fd); + // Given the four channels arguments, verify that: // // - if any is default foreground, all are default foreground diff --git a/src/lib/notcurses.c b/src/lib/notcurses.c index 061e59c29..c5eed9371 100644 --- a/src/lib/notcurses.c +++ b/src/lib/notcurses.c @@ -695,18 +695,6 @@ int ncplane_genocide(ncplane *ncp){ return ret; } -static int -make_nonblocking(int fd){ - if(fd < 0){ - return -1; - } - int flags = fcntl(fd, F_GETFL, 0); - if(flags < 0){ - return -1; - } - return fcntl(fd, F_SETFL, flags | O_NONBLOCK); -} - static void reset_stats(ncstats* stats){ uint64_t fbbytes = stats->fbbytes; @@ -1076,7 +1064,7 @@ notcurses* notcurses_core_init(const notcurses_options* opts, FILE* outfp){ if(ncinputlayer_init(&ret->input, stdin)){ goto err; } - if(make_nonblocking(ret->input.ttyinfd)){ + if(set_fd_nonblocking(ret->input.ttyinfd)){ goto err; } // Neither of these is supported on e.g. the "linux" virtual console. diff --git a/src/lib/render.c b/src/lib/render.c index 4ddeddc81..17fb5a3a4 100644 --- a/src/lib/render.c +++ b/src/lib/render.c @@ -79,7 +79,7 @@ blocking_write(int fd, const char* buf, size_t buflen){ while(written < buflen){ ssize_t w = write(fd, buf + written, buflen - written); if(w < 0){ - if(errno != EAGAIN && errno != EWOULDBLOCK){ + if(errno != EAGAIN && errno != EWOULDBLOCK && errno != EINTR){ return -1; } }else{