summaryrefslogtreecommitdiffstats
path: root/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/util')
-rw-r--r--src/util/debug.c10
-rw-r--r--src/util/util.h2
2 files changed, 7 insertions, 5 deletions
diff --git a/src/util/debug.c b/src/util/debug.c
index 54fb8011b..3bf5e75af 100644
--- a/src/util/debug.c
+++ b/src/util/debug.c
@@ -173,7 +173,7 @@ void ldb_debug_messages(void *context, enum ldb_debug_level level,
free(message);
}
-int open_debug_file_ex(const char *filename, FILE **filep)
+int open_debug_file_ex(const char *filename, FILE **filep, bool want_cloexec)
{
FILE *f = NULL;
char *logpath;
@@ -214,8 +214,10 @@ int open_debug_file_ex(const char *filename, FILE **filep)
return EIO;
}
- flags = fcntl(debug_fd, F_GETFD, 0);
- (void) fcntl(debug_fd, F_SETFD, flags | FD_CLOEXEC);
+ if(want_cloexec) {
+ flags = fcntl(debug_fd, F_GETFD, 0);
+ (void) fcntl(debug_fd, F_SETFD, flags | FD_CLOEXEC);
+ }
if (filep == NULL) {
debug_file = f;
@@ -228,7 +230,7 @@ int open_debug_file_ex(const char *filename, FILE **filep)
int open_debug_file(void)
{
- return open_debug_file_ex(NULL, NULL);
+ return open_debug_file_ex(NULL, NULL, true);
}
int rotate_debug_files(void)
diff --git a/src/util/util.h b/src/util/util.h
index d5ff9bb07..e61a94f7f 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -336,7 +336,7 @@ safealign_memcpy(void *dest, const void *src, size_t n, size_t *counter)
/* From debug.c */
void ldb_debug_messages(void *context, enum ldb_debug_level level,
const char *fmt, va_list ap);
-int open_debug_file_ex(const char *filename, FILE **filep);
+int open_debug_file_ex(const char *filename, FILE **filep, bool want_cloexec);
int open_debug_file(void);
int rotate_debug_files(void);
void talloc_log_fn(const char *msg);