hivex: Fix building on platforms without O_CLOEXEC such as FreeBSD
authorHilko Bengen <bengen@hilluzination.de>
Mon, 22 Aug 2011 17:52:02 +0000 (19:52 +0200)
committerRichard W.M. Jones <rjones@redhat.com>
Wed, 24 Aug 2011 11:56:51 +0000 (12:56 +0100)
lib/hivex.c

index a3f5171..4b9fcf0 100644 (file)
@@ -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)