[PATCH 2/3] Xext/shm: Better support cases where O_CLOEXEC is not defined

Julien Cristau jcristau at debian.org
Mon Sep 12 11:33:05 UTC 2016


On Sun, Sep 11, 2016 at 20:01:50 -0700, Jeremy Huddleston Sequoia wrote:

> Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
> ---
>  Xext/shm.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
Does anything have O_TMPFILE but not O_CLOEXEC?

Cheers,
Julien

> diff --git a/Xext/shm.c b/Xext/shm.c
> index 125000f..7a45dbd 100644
> --- a/Xext/shm.c
> +++ b/Xext/shm.c
> @@ -1202,7 +1202,11 @@ shm_tmpfile(void)
>  	int	flags;
>  	char	template[] = SHMDIR "/shmfd-XXXXXX";
>  #ifdef O_TMPFILE
> -	fd = open(SHMDIR, O_TMPFILE|O_RDWR|O_CLOEXEC|O_EXCL, 0666);
> +	flags = O_TMPFILE|O_RDWR|O_EXCL;
> +#ifdef O_CLOEXEC
> +	flags |= O_CLOEXEC;
> +#endif
> +	fd = open(SHMDIR, flags, 0666);
>  	if (fd >= 0) {
>  		ErrorF ("Using O_TMPFILE\n");
>  		return fd;
> -- 
> 2.10.0 (Apple Git-99)
> 
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: https://lists.x.org/mailman/listinfo/xorg-devel


More information about the xorg-devel mailing list