diff --git a/lib/util/close_low_fd.c b/lib/util/close_low_fd.c index 5e749187113..84a69067644 100644 --- a/lib/util/close_low_fd.c +++ b/lib/util/close_low_fd.c @@ -21,11 +21,22 @@ #include "system/filesys.h" #include "close_low_fd.h" +#ifdef HAVE_VALGRIND_VALGRIND_H +#include +#elif defined(HAVE_VALGRIND_H) +#include +#else +#define RUNNING_ON_VALGRIND 0 +#endif + _PUBLIC_ int close_low_fd(int fd) { -#ifndef VALGRIND int ret, dev_null; + if (RUNNING_ON_VALGRIND) { + return 0; + } + dev_null = open("/dev/null", O_RDWR, 0); if ((dev_null == -1) && (errno == ENFILE)) { @@ -60,6 +71,5 @@ _PUBLIC_ int close_low_fd(int fd) return err; } close(dev_null); -#endif return 0; }