diff options
| author | Leonardo Hernández Hernández <leohdz172@proton.me> | 2024-06-27 13:19:16 -0600 | 
|---|---|---|
| committer | Leonardo Hernández Hernández <leohdz172@proton.me> | 2024-07-01 20:40:54 -0600 | 
| commit | 71f11e6cf63289d51f152469a0da81a85fe2608c (patch) | |
| tree | c5b63e1836cfaf5289bcdc2938cac15d2e09e3f4 /util.c | |
| parent | 2b4893a0ad57fb5234c48615a2e531401efcf69c (diff) | |
set O_NONBLOCK flag to stdout
Diffstat (limited to 'util.c')
| -rw-r--r-- | util.c | 16 | 
1 files changed, 16 insertions, 0 deletions
| @@ -3,6 +3,7 @@  #include <stdio.h>  #include <stdlib.h>  #include <string.h> +#include <fcntl.h>  #include "util.h" @@ -33,3 +34,18 @@ ecalloc(size_t nmemb, size_t size)  		die("calloc:");  	return p;  } + +int +fd_set_nonblock(int fd) { +	int flags = fcntl(fd, F_GETFL); +    if (flags < 0) { +		perror("fcntl(F_GETFL):"); +        return -1; +    } +    if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) < 0) { +		perror("fcntl(F_SETFL):"); +		return -1; +    } + +	return 0; +} | 
