aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gdbmdefs.h3
-rw-r--r--src/gdbmopen.c8
-rw-r--r--src/gdbmreorg.c3
3 files changed, 12 insertions, 2 deletions
diff --git a/src/gdbmdefs.h b/src/gdbmdefs.h
index b5922e3..519d688 100644
--- a/src/gdbmdefs.h
+++ b/src/gdbmdefs.h
@@ -156,6 +156,9 @@ struct gdbm_file_info {
/* Whether or not we're allowing mmap() use. */
unsigned memory_mapping :1;
+
+ /* Whether the database was open with GDBM_CLOEXEC flag */
+ unsigned cloexec :1;
/* Type of file locking in use. */
enum { LOCKING_NONE = 0, LOCKING_FLOCK, LOCKING_LOCKF,
diff --git a/src/gdbmopen.c b/src/gdbmopen.c
index ddd82e2..67db9c2 100644
--- a/src/gdbmopen.c
+++ b/src/gdbmopen.c
@@ -122,7 +122,13 @@ gdbm_open (const char *file, int block_size, int flags, int mode,
dbf->file_locking = FALSE;
}
if (flags & GDBM_CLOEXEC)
- fbits = O_CLOEXEC;
+ {
+ fbits = O_CLOEXEC;
+ dbf->cloexec = TRUE;
+ }
+ else
+ dbf->cloexec = FALSE;
+
/* Open the file. */
need_trunc = FALSE;
switch (flags & GDBM_OPENMASK)
diff --git a/src/gdbmreorg.c b/src/gdbmreorg.c
index 5fc0d68..cc2a929 100644
--- a/src/gdbmreorg.c
+++ b/src/gdbmreorg.c
@@ -102,7 +102,8 @@ gdbm_reorganize (GDBM_FILE dbf)
new_name[len] = '#';
/* Open the new database. */
- new_dbf = gdbm_open (new_name, dbf->header->block_size, GDBM_WRCREAT,
+ new_dbf = gdbm_open (new_name, dbf->header->block_size,
+ GDBM_WRCREAT | (dbf->cloexec ? GDBM_CLOEXEC : 0),
fileinfo.st_mode, dbf->fatal_err);
if (new_dbf == NULL)

Return to:

Send suggestions and report system problems to the System administrator.