aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/nc/compat/accept4.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/apps/nc/compat/accept4.c b/apps/nc/compat/accept4.c
index dca42e9..7818bc0 100644
--- a/apps/nc/compat/accept4.c
+++ b/apps/nc/compat/accept4.c
@@ -5,12 +5,18 @@ int
5accept4(int s, struct sockaddr *addr, socklen_t *addrlen, int flags) 5accept4(int s, struct sockaddr *addr, socklen_t *addrlen, int flags)
6{ 6{
7 int rets = accept(s, addr, addrlen); 7 int rets = accept(s, addr, addrlen);
8 int fl;
8 if (rets == -1) 9 if (rets == -1)
9 return rets; 10 return rets;
10 11
11 if (flags & SOCK_CLOEXEC) { 12 if (flags & SOCK_CLOEXEC) {
12 flags = fcntl(rets, F_GETFD); 13 fl = fcntl(rets, F_GETFD);
13 fcntl(rets, F_SETFD, flags | FD_CLOEXEC); 14 fcntl(rets, F_SETFD, fl | FD_CLOEXEC);
15 }
16
17 if (flags & SOCK_NONBLOCK) {
18 fl = fcntl(rets, F_GETFL);
19 fcntl(rets, F_SETFL, fl | O_NONBLOCK);
14 } 20 }
15 21
16 return rets; 22 return rets;