[PATCH xserver 1/2] shm, xwayland: prefer atomic close-on-exec without O_TMPFILE

Julien Cristau jcristau at debian.org
Fri Jul 7 19:39:00 UTC 2017


On Fri, Jul  7, 2017 at 16:31:48 +0200, Jan Beich wrote:

> 
> Signed-off-by: Jan Beich <jbeich at FreeBSD.org>
> ---
>  Xext/shm.c              | 9 +++++++--
>  configure.ac            | 2 +-
>  include/dix-config.h.in | 3 +++
>  3 files changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/Xext/shm.c b/Xext/shm.c
> index 91ea90b14..6edeba6fb 100644
> --- a/Xext/shm.c
> +++ b/Xext/shm.c
> @@ -1199,7 +1199,6 @@ shm_tmpfile(void)
>  {
>  #ifdef SHMDIR
>  	int	fd;
> -	int	flags;
>  	char	template[] = SHMDIR "/shmfd-XXXXXX";
>  #ifdef O_TMPFILE
>  	fd = open(SHMDIR, O_TMPFILE|O_RDWR|O_CLOEXEC|O_EXCL, 0666);
> @@ -1209,15 +1208,21 @@ shm_tmpfile(void)
>  	}
>  	ErrorF ("Not using O_TMPFILE\n");
>  #endif
> +#ifdef HAVE_MKOSTEMP
> +	fd = mkostemp(template, O_CLOEXEC);
> +#else
>  	fd = mkstemp(template);
> +#endif
>  	if (fd < 0)
>  		return -1;
>  	unlink(template);
> -	flags = fcntl(fd, F_GETFD);
> +#ifndef HAVE_MKOSTEMP
> +	int flags = fcntl(fd, F_GETFD);

Do we allow mixed declarations and code nowadays?

Cheers,
Julien


More information about the xorg-devel mailing list