diff options
author | Blake Tregre <blake@oblong.com> | 2012-11-08 13:22:41 -0800 |
---|---|---|
committer | Olivier CrĂȘte <olivier.crete@collabora.com> | 2013-02-28 13:17:52 -0500 |
commit | 78ba68daafa38f8f9e02b3c25b8f99ade91329af (patch) | |
tree | e39c64ea652946e096f26ceddb59317617f6c2bc | |
parent | fdfbb3c0733ddc46fbf78783ff2b7b84bd12ba1f (diff) |
shm: use O_CLOEXEC where appropriate in shmpipe
https://bugzilla.gnome.org/show_bug.cgi?id=684339
-rw-r--r-- | sys/shm/shmpipe.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/sys/shm/shmpipe.c b/sys/shm/shmpipe.c index d61db2503..ad703d8a7 100644 --- a/sys/shm/shmpipe.c +++ b/sys/shm/shmpipe.c @@ -749,6 +749,7 @@ sp_client_open (const char *path) { ShmPipe *self = spalloc_new (ShmPipe); struct sockaddr_un sock_un; + int flags; memset (self, 0, sizeof (ShmPipe)); @@ -758,6 +759,13 @@ sp_client_open (const char *path) if (self->main_socket < 0) goto error; + flags = fcntl (self->main_socket, F_GETFL, 0); + if (flags < 0) + goto error; + + if (fcntl (self->main_socket, F_SETFL, flags | FD_CLOEXEC) < 0) + goto error; + sock_un.sun_family = AF_UNIX; strncpy (sock_un.sun_path, path, sizeof (sock_un.sun_path) - 1); |