int XdevLWindowWayland::createTmpFileCloExec(char *tmpname) {
		int fd;

#ifdef HAVE_MKOSTEMP
		fd = mkostemp(tmpname, O_CLOEXEC);
		if(fd >= 0)
			unlink(tmpname);
#else
		fd = mkstemp(tmpname);
		if(fd >= 0) {
			fd = setCloexecOrClose(fd);
			unlink(tmpname);
		}
#endif

		return fd;
	}
示例#2
0
static int
createTmpFileCloexec(char *tmpname)
{
    int fd;
#ifdef HAVE_MKOSTEMP
    fd = mkostemp(tmpname, O_CLOEXEC);
    if (fd >= 0){
        unlink(tmpname);
    }
#else
    fd = mkstemp(tmpname);
    if (fd >= 0){
        fd = setCloexecOrClose(fd);
        unlink(tmpname);
    }
#endif
    return fd;
}