diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/include/skalibs/djbunix.h | 1 | ||||
-rw-r--r-- | src/libstddjb/fd_shutdown.c | 14 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/include/skalibs/djbunix.h b/src/include/skalibs/djbunix.h index 3c52f6a..03cc1af 100644 --- a/src/include/skalibs/djbunix.h +++ b/src/include/skalibs/djbunix.h @@ -34,6 +34,7 @@ extern int fd_cat (int, int) ; extern size_t fd_catn (int, int, size_t) ; extern int fd_ensure_open (int, int) ; #define fd_sanitize() (fd_ensure_open(0, 0) && fd_ensure_open(1, 1) && fd_ensure_open(2, 1)) +extern void fd_shutdown (int, int) ; extern int lock_ex (int) ; extern int lock_exnb (int) ; extern int lock_sh (int) ; diff --git a/src/libstddjb/fd_shutdown.c b/src/libstddjb/fd_shutdown.c new file mode 100644 index 0000000..52e00c7 --- /dev/null +++ b/src/libstddjb/fd_shutdown.c @@ -0,0 +1,14 @@ +/* ISC license. */ + +#include <skalibs/nonposix.h> +#include <errno.h> +#include <sys/socket.h> + +#include <skalibs/djbunix.h> + +void fd_shutdown (int fd, int h) +{ + int e = errno ; + shutdown(fd, h ? SHUT_WR : SHUT_RD) ; + errno = e ; +} |