From 3d051d41a3034f253da94ce7eef4af579089cb64 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 5 Jan 2015 14:25:14 -0800 Subject: [PATCH] Fix forkfd build when O_CLOEXEC isn't defined. O_CLOEXEC was introduced with the 2008 revision of POSIX.1 and it's the only way of doing child processes safely with fork(2) in multithreaded applications. But we need to support pre-2008 systems, so we can't use that constant. So let's just choose two arbitrary values for both of our constants -- we need to change both because we need to be sure that FFD_CLOEXEC won't be the same as FFD_NONBLOCK. Linux will probably implement them to the O_ constants, like epoll, signalfd and inotify have done. Change-Id: I20a5aa6e6264e7a219e19759eeb8747e01df05ff Reviewed-by: Giuseppe D'Angelo Reviewed-by: Rafael Roquetto --- src/3rdparty/forkfd/forkfd.c | 2 +- src/3rdparty/forkfd/forkfd.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/3rdparty/forkfd/forkfd.c b/src/3rdparty/forkfd/forkfd.c index b781b517a6d..067e41d4868 100644 --- a/src/3rdparty/forkfd/forkfd.c +++ b/src/3rdparty/forkfd/forkfd.c @@ -404,7 +404,7 @@ int forkfd(int flags, pid_t *ppid) #endif { /* try a pipe */ - if (create_pipe(sync_pipe, O_CLOEXEC) == -1) { + if (create_pipe(sync_pipe, FFD_CLOEXEC) == -1) { /* failed both at eventfd and pipe; fail and pass errno */ goto err_close; } diff --git a/src/3rdparty/forkfd/forkfd.h b/src/3rdparty/forkfd/forkfd.h index de75f84bc0f..01b8882623b 100644 --- a/src/3rdparty/forkfd/forkfd.h +++ b/src/3rdparty/forkfd/forkfd.h @@ -44,8 +44,8 @@ extern "C" { #endif -#define FFD_CLOEXEC O_CLOEXEC -#define FFD_NONBLOCK O_NONBLOCK +#define FFD_CLOEXEC 1 +#define FFD_NONBLOCK 2 #define FFD_CHILD_PROCESS (-2)