From aca530bc5bf975f670ce7e51b75f8c65f79ce858 Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Tue, 1 May 2018 23:50:15 -0500 Subject: [PATCH] Use shared memory instead of temp files on FreeBSD-compatible OS --- uwac/libuwac/uwac-os.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/uwac/libuwac/uwac-os.c b/uwac/libuwac/uwac-os.c index ec9efe47b..212e19548 100644 --- a/uwac/libuwac/uwac-os.c +++ b/uwac/libuwac/uwac-os.c @@ -29,8 +29,15 @@ #define _GNU_SOURCE +#if defined(__FreeBSD__) || defined(__DragonFly__) +#define USE_SHM +#endif + #include #include +#ifdef USE_SHM +#include +#endif #include #include #include @@ -153,7 +160,9 @@ static int create_tmpfile_cloexec(char *tmpname) { int fd; -#ifdef HAVE_MKOSTEMP +#ifdef USE_SHM + fd = shm_open(SHM_ANON, O_CREAT | O_RDWR, 0600); +#elif defined(HAVE_MKOSTEMP) fd = mkostemp(tmpname, O_CLOEXEC); if (fd >= 0) unlink(tmpname);