diff --git a/c_src/Makefile b/c_src/Makefile index 9f8cbdb..e9689aa 100644 --- a/c_src/Makefile +++ b/c_src/Makefile @@ -7,6 +7,7 @@ ERL_CXXFLAGS ?= $(shell erl -noshell -noinput -eval "io:format(\"-I~ts/erts-~ts/ ERL_LDFLAGS ?= $(shell erl -noshell -noinput -eval "io:format(\"-L~ts\", [code:lib_dir(erl_interface, lib)]), halt(0).") CXXFLAGS += -g -std=c++11 -finline-functions -Wall -DHAVE_PTRACE -MMD +USE_POLL ?= 1 UNAME_SYS := $(shell uname -s | tr 'A-Z' 'a-z') @@ -26,8 +27,8 @@ endif # By default use poll(2). If USE_POLL=0 is defined, use select(2): -ifneq ($(filter $(USE_POLL),1 true),) - CXXFLAGS += -DUSE_POLL=1 +ifneq ($(filter $(USE_POLL),0 1 true),) + CXXFLAGS += -DUSE_POLL=$(USE_POLL) endif ifeq ($(findstring $(TARGET),linux),) diff --git a/c_src/exec.cpp b/c_src/exec.cpp index af87c1d..7518f06 100644 --- a/c_src/exec.cpp +++ b/c_src/exec.cpp @@ -58,7 +58,7 @@ */ #include "exec.hpp" -#if defined(USE_POLL) && USE_POLL > 0 +#if defined(USE_POLL) && USE_POLL # include #endif @@ -618,7 +618,7 @@ void initialize(int userid, bool use_alt_fds, bool is_root, bool requested_root) DEBUG(debug, "Initializing: uid=%d, userid=%d%s%s%s", getuid(), userid, is_root ? " is-root":"", requested_root ? " requested-root":"", - #if defined(USE_POLL) && USE_POLL > 0 + #if defined(USE_POLL) && USE_POLL ", use-poll=1" #else "" diff --git a/c_src/exec_impl.cpp b/c_src/exec_impl.cpp index 1fb2229..2f1b199 100644 --- a/c_src/exec_impl.cpp +++ b/c_src/exec_impl.cpp @@ -26,7 +26,7 @@ int ptsname_r(int fd, char* buf, size_t buflen) { //------------------------------------------------------------------------------ // CmdInfo //------------------------------------------------------------------------------ -#if !defined(USE_POLL) || (USE_POLL == 0) +#if !defined(USE_POLL) || !USE_POLL void CmdInfo::include_stream_fd(FdHandler &fdhandler) { for (int i=STDIN_FILENO; i <= STDERR_FILENO; i++) { @@ -59,7 +59,7 @@ void CmdInfo::process_stream_data(FdHandler &fdhandler) } #endif /* !defined(USE_POLL) */ -#if defined(USE_POLL) && USE_POLL > 0 +#if defined(USE_POLL) && USE_POLL void CmdInfo::include_stream_fd(FdHandler &fdhandler) { for (int i=STDIN_FILENO; i <= STDERR_FILENO; i++) {