diff options
author | Brent Cook <bcook@openbsd.org> | 2015-09-13 11:56:41 -0500 |
---|---|---|
committer | Brent Cook <bcook@openbsd.org> | 2015-09-13 18:42:15 -0500 |
commit | 8c90be2a29053ac613dfe0c11a423da16c7c4520 (patch) | |
tree | cf31a8e35cd9793f5f6f622b0ffcce61bbad8652 /apps/nc/compat/accept4.c | |
parent | 627b0261a81bb18ef95156baa37101ddcb14e356 (diff) | |
download | portable-8c90be2a29053ac613dfe0c11a423da16c7c4520.tar.gz portable-8c90be2a29053ac613dfe0c11a423da16c7c4520.tar.bz2 portable-8c90be2a29053ac613dfe0c11a423da16c7c4520.zip |
allow nc to build on linux and os x
Diffstat (limited to 'apps/nc/compat/accept4.c')
-rw-r--r-- | apps/nc/compat/accept4.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/apps/nc/compat/accept4.c b/apps/nc/compat/accept4.c new file mode 100644 index 0000000..278198b --- /dev/null +++ b/apps/nc/compat/accept4.c | |||
@@ -0,0 +1,17 @@ | |||
1 | #include <sys/socket.h> | ||
2 | #include <fcntl.h> | ||
3 | |||
4 | int | ||
5 | accept4(int s, struct sockaddr *addr, socklen_t *addrlen, int flags) | ||
6 | { | ||
7 | int rets = accept(s, addr, addrlen); | ||
8 | if (rets == -1) | ||
9 | return s; | ||
10 | |||
11 | if (flags & SOCK_CLOEXEC) { | ||
12 | flags = fcntl(s, F_GETFD); | ||
13 | fcntl(rets, F_SETFD, flags | FD_CLOEXEC); | ||
14 | } | ||
15 | |||
16 | return rets; | ||
17 | } | ||