diff --git a/mongoose.c b/mongoose.c index e91bb021..6804a8a3 100644 --- a/mongoose.c +++ b/mongoose.c @@ -2976,7 +2976,8 @@ static void mg_set_non_blocking_mode(SOCKET fd) { #elif MG_ARCH == MG_ARCH_AZURERTOS fcntl(fd, F_SETFL, O_NONBLOCK); #else - fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NONBLOCK | FD_CLOEXEC); + fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK); // Set non-blocking mode + fcntl(fd, F_SETFD, FD_CLOEXEC); // Set close-on-exec #endif } diff --git a/src/sock.c b/src/sock.c index 4962caa9..6725a075 100644 --- a/src/sock.c +++ b/src/sock.c @@ -134,7 +134,8 @@ static void mg_set_non_blocking_mode(SOCKET fd) { #elif MG_ARCH == MG_ARCH_AZURERTOS fcntl(fd, F_SETFL, O_NONBLOCK); #else - fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NONBLOCK | FD_CLOEXEC); + fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK); // Set non-blocking mode + fcntl(fd, F_SETFD, FD_CLOEXEC); // Set close-on-exec #endif }