We should not skip all of close_low_fd() just because we
detected valgrind headers at build time.
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
#include "system/filesys.h"
#include "close_low_fd.h"
+#ifdef HAVE_VALGRIND_VALGRIND_H
+#include <valgrind/valgrind.h>
+#elif defined(HAVE_VALGRIND_H)
+#include <valgrind.h>
+#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)) {
return err;
}
close(dev_null);
-#endif
return 0;
}