1*a192d1c0SPatrick Mooney /*
2*a192d1c0SPatrick Mooney  * This file and its contents are supplied under the terms of the
3*a192d1c0SPatrick Mooney  * Common Development and Distribution License ("CDDL"), version 1.0.
4*a192d1c0SPatrick Mooney  * You may only use this file in accordance with the terms of version
5*a192d1c0SPatrick Mooney  * 1.0 of the CDDL.
6*a192d1c0SPatrick Mooney  *
7*a192d1c0SPatrick Mooney  * A full copy of the text of the CDDL should have accompanied this
8*a192d1c0SPatrick Mooney  * source.  A copy of the CDDL is also available via the Internet at
9*a192d1c0SPatrick Mooney  * http://www.illumos.org/license/CDDL.
10*a192d1c0SPatrick Mooney  */
11*a192d1c0SPatrick Mooney 
12*a192d1c0SPatrick Mooney /*
13*a192d1c0SPatrick Mooney  * Copyright 2016 Joyent, Inc.
14*a192d1c0SPatrick Mooney  */
15*a192d1c0SPatrick Mooney 
16*a192d1c0SPatrick Mooney 
17*a192d1c0SPatrick Mooney #include <stdlib.h>
18*a192d1c0SPatrick Mooney #include <stdio.h>
19*a192d1c0SPatrick Mooney #include <unistd.h>
20*a192d1c0SPatrick Mooney #include <fcntl.h>
21*a192d1c0SPatrick Mooney #include <sys/epoll.h>
22*a192d1c0SPatrick Mooney #include <errno.h>
23*a192d1c0SPatrick Mooney #include <assert.h>
24*a192d1c0SPatrick Mooney 
25*a192d1c0SPatrick Mooney int
main()26*a192d1c0SPatrick Mooney main()
27*a192d1c0SPatrick Mooney {
28*a192d1c0SPatrick Mooney 	int fd, flags;
29*a192d1c0SPatrick Mooney 
30*a192d1c0SPatrick Mooney 	fd = epoll_create1(0);
31*a192d1c0SPatrick Mooney 	assert(fd >= 0);
32*a192d1c0SPatrick Mooney 
33*a192d1c0SPatrick Mooney 	flags = fcntl(fd, F_GETFD);
34*a192d1c0SPatrick Mooney 	assert(flags != -1 && (flags & FD_CLOEXEC) == 0);
35*a192d1c0SPatrick Mooney 	(void) close(fd);
36*a192d1c0SPatrick Mooney 
37*a192d1c0SPatrick Mooney 
38*a192d1c0SPatrick Mooney 	fd = epoll_create1(EPOLL_CLOEXEC);
39*a192d1c0SPatrick Mooney 	assert(fd >= 0);
40*a192d1c0SPatrick Mooney 
41*a192d1c0SPatrick Mooney 	flags = fcntl(fd, F_GETFD);
42*a192d1c0SPatrick Mooney 	assert(flags != -1 && (flags & FD_CLOEXEC) == FD_CLOEXEC);
43*a192d1c0SPatrick Mooney 	(void) close(fd);
44*a192d1c0SPatrick Mooney 
45*a192d1c0SPatrick Mooney 	fd = epoll_create1(EPOLL_CLOEXEC * 3);
46*a192d1c0SPatrick Mooney 	assert(fd == -1 && errno == EINVAL);
47*a192d1c0SPatrick Mooney 	fd = epoll_create1(EPOLL_CLOEXEC * 2);
48*a192d1c0SPatrick Mooney 	assert(fd == -1 && errno == EINVAL);
49*a192d1c0SPatrick Mooney 
50*a192d1c0SPatrick Mooney 	return (0);
51*a192d1c0SPatrick Mooney }