--- mm_core.c 2002/07/26 13:48:38 1.16
+++ mm_core.c 2002/12/19 09:11:51 1.17
@@ -130,6 +130,9 @@
}
if (fd == -1 && i < MM_MAXCHILD) {
fd = open(mc->mc_fnsem, O_WRONLY, MM_CORE_FILEMODE);
+#if defined(F_SETFD) && defined(FD_CLOEXEC)
+ fcntl(fd, F_SETFD, FD_CLOEXEC);
+#endif
mc->mc_fdsem[i].pid = getpid();
mc->mc_fdsem[i].fd = fd;
}
@@ -264,6 +267,10 @@
#if defined(MM_SHMT_MMZERO)
if ((fdmem = open("/dev/zero", O_RDWR, MM_CORE_FILEMODE)) == -1)
FAIL(MM_ERR_CORE|MM_ERR_SYSTEM, "failed to open /dev/zero");
+#if defined(F_SETFD) && defined(FD_CLOEXEC)
+ if (fcntl(fdmem, F_SETFD, FD_CLOEXEC) == -1)
+ FAIL(MM_ERR_CORE|MM_ERR_SYSTEM, "failed to set close-on-exec flag");
+#endif
if (lseek(fdmem, mm_core_mapoffset+size, SEEK_SET) == -1)
FAIL(MM_ERR_CORE|MM_ERR_SYSTEM, "failed to seek in /dev/zero");
write(fdmem, &zero, sizeof(zero));
@@ -277,6 +284,10 @@
unlink(fnmem);
if ((fdmem = open(fnmem, O_RDWR|O_CREAT|O_EXCL, MM_CORE_FILEMODE)) == -1)
FAIL(MM_ERR_CORE|MM_ERR_SYSTEM, "failed to open memory file");
+#if defined(F_SETFD) && defined(FD_CLOEXEC)
+ if (fcntl(fdmem, F_SETFD, FD_CLOEXEC) == -1)
+ FAIL(MM_ERR_CORE|MM_ERR_SYSTEM, "failed to set close-on-exec flag");
+#endif
if (ftruncate(fdmem, mm_core_mapoffset+size) == -1)
FAIL(MM_ERR_CORE|MM_ERR_SYSTEM, "failed to truncate memory file");
write(fdmem, &zero, sizeof(zero));
@@ -305,12 +316,20 @@
unlink(fnsem);
if ((fdsem = open(fnsem, O_RDWR|O_CREAT|O_EXCL, MM_CORE_FILEMODE)) == -1)
FAIL(MM_ERR_CORE|MM_ERR_SYSTEM, "failed to open semaphore file");
+#if defined(F_SETFD) && defined(FD_CLOEXEC)
+ if (fcntl(fdsem, F_SETFD, FD_CLOEXEC) == -1)
+ FAIL(MM_ERR_CORE|MM_ERR_SYSTEM, "failed to set close-on-exec flag");
+#endif
#endif /* MM_SEMT_FLOCK */
#if defined(MM_SEMT_FCNTL)
unlink(fnsem);
if ((fdsem = open(fnsem, O_RDWR|O_CREAT|O_EXCL, MM_CORE_FILEMODE)) == -1)
FAIL(MM_ERR_CORE|MM_ERR_SYSTEM, "failed to open semaphore file");
+#if defined(F_SETFD) && defined(FD_CLOEXEC)
+ if (fcntl(fdsem, F_SETFD, FD_CLOEXEC) == -1)
+ FAIL(MM_ERR_CORE|MM_ERR_SYSTEM, "failed to set close-on-exec flag");
+#endif
#endif /* MM_SEMT_FCNTL */
#if defined(MM_SEMT_IPCSEM)
|