# HG changeset patch # User jbe # Date 1435004381 -7200 # Node ID 453b7d1a79445e39569e80fa4f3ed2cdd6ecdb8d # Parent a3d569d3e85d9a5f1caab74da747bfdd8af1cb2c Avoid use of accept4() function in favor of accept() to avoid using _GNU_SOURCE on GNU/Linux diff -r a3d569d3e85d -r 453b7d1a7944 moonbridge.c --- a/moonbridge.c Mon Jun 22 21:26:33 2015 +0200 +++ b/moonbridge.c Mon Jun 22 22:19:41 2015 +0200 @@ -17,9 +17,6 @@ /*** Include directives for used system libraries ***/ -#if defined(__linux__) -#define _GNU_SOURCE -#endif #include #include #include @@ -1435,7 +1432,15 @@ } else { int peerfd; do { - peerfd = accept4(listener->listenfd, NULL, NULL, SOCK_CLOEXEC); + /* peerfd = accept4(listener->listenfd, NULL, NULL, SOCK_CLOEXEC); */ + /* use accept() instead of accept4() to avoid _GNU_SOURCE on GNU/Linux */ + peerfd = accept(listener->listenfd, NULL, NULL); + if (peerfd != -1) { + if (fcntl(peerfd, F_SETFD, FD_CLOEXEC) == -1) { + moonbr_log(LOG_ERR, "Error in fcntl() call: %s", strerror(errno)); + moonbr_terminate_error(); + } + } if (peerfd == -1) { if (errno == EWOULDBLOCK) { break; diff -r a3d569d3e85d -r 453b7d1a7944 moonbridge_io.c --- a/moonbridge_io.c Mon Jun 22 21:26:33 2015 +0200 +++ b/moonbridge_io.c Mon Jun 22 22:19:41 2015 +0200 @@ -3,9 +3,6 @@ #define __has_include(x) 0 #endif -#if defined(__linux__) -#define _GNU_SOURCE -#endif #include #include #include