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;
}
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;

@ -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

@ -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.

@ -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{

Loading…
Cancel
Save