@@ -32,7 +32,6 @@
#include <lttng/align.h>
#include <limits.h>
#include <helper.h>
-
/*
* Ensure we have the required amount of space available by writing 0
* into the entire buffer. Not doing so can trigger SIGBUS when going
@@ -122,6 +121,12 @@ struct shm_object *_shm_object_table_alloc_shm(struct shm_object_table *table,
/* create shm */
shmfd = stream_fd;
+ if (shmfd >= 0) {
+ ret = fcntl(shmfd, F_SETFD, FD_CLOEXEC);
+ if (ret < 0) {
+ PERROR("fcntl shmfd FD_CLOEXEC");
+ }
+ }
ret = zero_file(shmfd, memory_map_size);
if (ret) {
PERROR("zero_file");
@@ -272,15 +277,22 @@ struct shm_object *shm_object_table_append_shm(struct shm_object_table *table,
obj->shm_fd = shm_fd;
obj->shm_fd_ownership = 1;
+ if (shm_fd >= 0) {
+ ret = fcntl(shm_fd, F_SETFD, FD_CLOEXEC);
+ if (ret < 0) {
+ PERROR("fcntl shmfd FD_CLOEXEC");
+ //goto error_fcntl;
+ }
+ }
ret = fcntl(obj->wait_fd[1], F_SETFD, FD_CLOEXEC);
if (ret < 0) {
As it shows, wait_fd[1] has been set FD_CLOEXEC by fcntl() but not shm_fd. Why your patch do with wait_fd but not shm_fd? As far as I know, wait_fd is just a pipe and it seems not related to shm resource.
------------------------------------------------------------------
????Mathieu Desnoyers <mathieu.desnoyers at efficios.com>