/*
 * W^X mmap(2) on file
 */

#include <errno.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <unistd.h>

int main(void)
{
	char path[] = "/tmp/t087_XXXXXX";
	int fd = mkstemp(path);
	if (fd < 0) return errno;
	ftruncate(fd, 4096);
	unlink(path);
	errno = 0;
	void *p = mmap(NULL, 4096, PROT_WRITE | PROT_EXEC,
	               MAP_SHARED, fd, 0);
	return errno;
}
