diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/arch/unix/apr_arch_inherit.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/include/arch/unix/apr_arch_inherit.h b/include/arch/unix/apr_arch_inherit.h index 9a6bdbca5..6ae2435f0 100644 --- a/include/arch/unix/apr_arch_inherit.h +++ b/include/arch/unix/apr_arch_inherit.h @@ -27,6 +27,12 @@ apr_status_t apr_##name##_inherit_set(apr_##name##_t *the##name) \ if (the##name->flag & APR_FILE_NOCLEANUP) \ return APR_EINVAL; \ if (!(the##name->flag & APR_INHERIT)) { \ + int flags = fcntl(the##name->name##des, F_GETFD); \ + if (flags == -1) \ + return errno; \ + flags &= ~(FD_CLOEXEC); \ + if (fcntl(the##name->name##des, F_SETFD, flags) == -1) \ + return errno; \ the##name->flag |= APR_INHERIT; \ apr_pool_child_cleanup_set(the##name->pool, \ (void *)the##name, \ @@ -41,6 +47,12 @@ apr_status_t apr_##name##_inherit_unset(apr_##name##_t *the##name) \ if (the##name->flag & APR_FILE_NOCLEANUP) \ return APR_EINVAL; \ if (the##name->flag & APR_INHERIT) { \ + int flags; \ + if ((flags = fcntl(the##name->name##des, F_GETFD)) == -1) \ + return errno; \ + flags |= FD_CLOEXEC; \ + if (fcntl(the##name->name##des, F_SETFD, flags) == -1) \ + return errno; \ the##name->flag &= ~APR_INHERIT; \ apr_pool_child_cleanup_set(the##name->pool, \ (void *)the##name, \ |