From 84bc18684e40475d724c3163b4a2b116a62a2aa6 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sat, 29 Oct 2011 05:32:22 +0200 Subject: [PATCH] linux: omit superfluous fcntl(F_GETFD) syscall --- src/unix/core.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/unix/core.c b/src/unix/core.c index 706c89eb..0b81bc50 100644 --- a/src/unix/core.c +++ b/src/unix/core.c @@ -763,6 +763,12 @@ int uv__nonblock(int fd, int set) { int uv__cloexec(int fd, int set) { +#if __linux__ + /* Linux knows only FD_CLOEXEC so we can safely omit the fcntl(F_GETFD) + * syscall. CHECKME: That's probably true for other Unices as well. + */ + return fcntl(fd, F_SETFD, set ? FD_CLOEXEC : 0); +#else int flags; if ((flags = fcntl(fd, F_GETFD)) == -1) { @@ -780,6 +786,7 @@ int uv__cloexec(int fd, int set) { } return 0; +#endif }