aboutsummaryrefslogtreecommitdiff
path: root/x11/libxshmfence/files/patch-src__xshmfence_alloc.c
blob: ea14877817ec592361782b90d251f232e2d2a42b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
--- src/xshmfence_alloc.c.orig	2015-03-04 15:28:23 UTC
+++ src/xshmfence_alloc.c
@@ -67,15 +67,19 @@ int
 xshmfence_alloc_shm(void)
 {
 	char	template[] = SHMDIR "/shmfd-XXXXXX";
-	int	fd;
+	int	fd = -1;
 
 #if HAVE_MEMFD_CREATE
 	fd = memfd_create("xshmfence", MFD_CLOEXEC|MFD_ALLOW_SEALING);
 	if (fd < 0)
 #endif
 	{
-#ifdef O_TMPFILE
+#if defined(O_CLOEXEC)
+#if defined(HAVE_MKOSTEMP)
+		fd = mkostemp(template, O_CLOEXEC);
+#elif defined(O_TMPFILE)
 		fd = open(SHMDIR, O_TMPFILE|O_RDWR|O_CLOEXEC|O_EXCL, 0666);
+#endif
 		if (fd < 0)
 #endif
 		{