From c175c6b3d083f6bf3798cd172b38c4979b067c73 Mon Sep 17 00:00:00 2001 From: Blake Tregre Date: Thu, 8 Nov 2012 13:22:41 -0800 Subject: shm: use O_CLOEXEC where appropriate in shmpipe https://bugzilla.gnome.org/show_bug.cgi?id=684339 --- sys/shm/shmpipe.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'sys/shm/shmpipe.c') diff --git a/sys/shm/shmpipe.c b/sys/shm/shmpipe.c index 676453b37..6c7b80be7 100644 --- a/sys/shm/shmpipe.c +++ b/sys/shm/shmpipe.c @@ -759,6 +759,7 @@ sp_client_open (const char *path) { ShmPipe *self = spalloc_new (ShmPipe); struct sockaddr_un sock_un; + int flags; memset (self, 0, sizeof (ShmPipe)); @@ -768,6 +769,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); -- cgit v1.2.1