diff options
| author | Raghuram Subramani <raghus2247@gmail.com> | 2024-07-07 18:42:35 +0530 |
|---|---|---|
| committer | Raghuram Subramani <raghus2247@gmail.com> | 2024-07-07 18:42:35 +0530 |
| commit | dde1d66ddc3236d076858736fb6faaf06a3c7d8c (patch) | |
| tree | 343bcd27455005413bcfea3aad8a6f1a4b4e7566 /util.c | |
| parent | 21ef958760beea3cacf9ae5937101348bd6ecc4c (diff) | |
updstream
Diffstat (limited to '')
| -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; +} |
