diff options
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 | } | ||