From: Hilko Bengen Date: Mon, 22 Aug 2011 17:52:02 +0000 (+0200) Subject: hivex: Fix building on platforms without O_CLOEXEC such as FreeBSD X-Git-Tag: 1.3.1~2 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=24e778286a2d684cb08afb29f5c0e48b2b312e7e;p=hivex.git hivex: Fix building on platforms without O_CLOEXEC such as FreeBSD --- 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)