From 24e778286a2d684cb08afb29f5c0e48b2b312e7e Mon Sep 17 00:00:00 2001 From: Hilko Bengen Date: Mon, 22 Aug 2011 19:52:02 +0200 Subject: [PATCH] hivex: Fix building on platforms without O_CLOEXEC such as FreeBSD --- lib/hivex.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/hivex.c b/lib/hivex.c index a3f5171..4b9fcf0 100644 --- a/lib/hivex.c +++ b/lib/hivex.c @@ -294,9 +294,16 @@ hivex_open (const char *filename, int flags) if (h->filename == NULL) goto error; +#ifdef O_CLOEXEC h->fd = open (filename, O_RDONLY | O_CLOEXEC); +#else + h->fd = open (filename, O_RDONLY); +#endif if (h->fd == -1) goto error; +#ifndef O_CLOEXEC + fcntl (h->fd, F_SETFD, FD_CLOEXEC); +#endif struct stat statbuf; if (fstat (h->fd, &statbuf) == -1) -- 1.8.3.1