about summary refs log tree commit diff
path: root/src/thread
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2012-09-29 16:48:52 -0400
committerRich Felker <dalias@aerifal.cx>2012-09-29 16:48:52 -0400
commit39f296a95b02925b8c3439e140a5668e36055d9b (patch)
tree23254ce5fd78cdb58176bdcac3ef4543f398bc7f /src/thread
parentc983e6415abdc30893b2fe359a334033c59ec621 (diff)
downloadmusl-39f296a95b02925b8c3439e140a5668e36055d9b.tar.gz
musl-39f296a95b02925b8c3439e140a5668e36055d9b.tar.xz
musl-39f296a95b02925b8c3439e140a5668e36055d9b.zip
use O_CLOEXEC to open semaphore files in sem_open
Diffstat (limited to 'src/thread')
-rw-r--r--src/thread/sem_open.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/thread/sem_open.c b/src/thread/sem_open.c
index d8d68392..0361a769 100644
--- a/src/thread/sem_open.c
+++ b/src/thread/sem_open.c
@@ -75,9 +75,9 @@ sem_t *sem_open(const char *name, int flags, ...)
 		clock_gettime(CLOCK_REALTIME, &ts);
 		snprintf(tmp, sizeof(tmp), "/dev/shm/%p-%p-%d-%d",
 			&name, name, (int)getpid(), (int)ts.tv_nsec);
-		tfd = open(tmp, O_CREAT|O_EXCL|O_RDWR, mode);
+		tfd = open(tmp, O_CREAT|O_EXCL|O_RDWR|O_CLOEXEC, mode);
 		if (tfd<0) return SEM_FAILED;
-		dir = open("/dev/shm", O_DIRECTORY|O_RDONLY);
+		dir = open("/dev/shm", O_DIRECTORY|O_RDONLY|O_CLOEXEC);
 		if (dir<0 || write(tfd,&newsem,sizeof newsem)!=sizeof newsem) {
 			if (dir >= 0) close(dir);
 			close(tfd);