aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo Buehler <tb@openbsd.org>2026-07-20 10:46:06 +0200
committerTheo Buehler <tb@openbsd.org>2026-07-20 10:46:06 +0200
commit7f0d9138798bc97628d64d2f316b335476ab90f7 (patch)
treeaa6b29fea933daa8cdda0e042b393d30b5f8d26c
parent2ebaff40de470a53dc0c2658b219535824104401 (diff)
parent5c7dd432a6d2141a422b40c5e33ff2e43c1b9667 (diff)
downloadportable-7f0d9138798bc97628d64d2f316b335476ab90f7.tar.gz
portable-7f0d9138798bc97628d64d2f316b335476ab90f7.tar.bz2
portable-7f0d9138798bc97628d64d2f316b335476ab90f7.zip
Land #1323 - honor SOCK_NONBLOCK in accept4 shim
-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;