eliminate duplicate set_fd_nonblocking()

pull/1383/head
nick black 4 years ago
parent a759f9ba0b
commit 7e451c42d2
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -79,8 +79,7 @@ ncfdplane_thread(void* vncfp){
return NULL; return NULL;
} }
static int int set_fd_nonblocking(int fd){
set_fd_nonblocking(int fd){
int flags = fcntl(fd, F_GETFL, 0); int flags = fcntl(fd, F_GETFL, 0);
if(flags < 0){ if(flags < 0){
return -1; return -1;

@ -1152,6 +1152,8 @@ int ncinputlayer_init(ncinputlayer* nilayer, FILE* infp);
// FIXME absorb into ncinputlayer_init() // FIXME absorb into ncinputlayer_init()
int cbreak_mode(int ttyfd, const struct termios* tpreserved); int cbreak_mode(int ttyfd, const struct termios* tpreserved);
int set_fd_nonblocking(int fd);
// Given the four channels arguments, verify that: // Given the four channels arguments, verify that:
// //
// - if any is default foreground, all are default foreground // - if any is default foreground, all are default foreground

@ -695,18 +695,6 @@ int ncplane_genocide(ncplane *ncp){
return ret; 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 static void
reset_stats(ncstats* stats){ reset_stats(ncstats* stats){
uint64_t fbbytes = stats->fbbytes; 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)){ if(ncinputlayer_init(&ret->input, stdin)){
goto err; goto err;
} }
if(make_nonblocking(ret->input.ttyinfd)){ if(set_fd_nonblocking(ret->input.ttyinfd)){
goto err; goto err;
} }
// Neither of these is supported on e.g. the "linux" virtual console. // Neither of these is supported on e.g. the "linux" virtual console.

@ -79,7 +79,7 @@ blocking_write(int fd, const char* buf, size_t buflen){
while(written < buflen){ while(written < buflen){
ssize_t w = write(fd, buf + written, buflen - written); ssize_t w = write(fd, buf + written, buflen - written);
if(w < 0){ if(w < 0){
if(errno != EAGAIN && errno != EWOULDBLOCK){ if(errno != EAGAIN && errno != EWOULDBLOCK && errno != EINTR){
return -1; return -1;
} }
}else{ }else{

Loading…
Cancel
Save