/* Sample testcase */
#include <sys/epoll.h>
#include <assert.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int
main(int argc, char *argv[])
{
struct epoll_event event, events[1];
int epfd, err, n;
epfd = epoll_create1(EPOLL_CLOEXEC);
assert(epfd);
event.events = EPOLLOUT | EPOLLONESHOT;
err = epoll_ctl(epfd, EPOLL_CTL_ADD, STDOUT_FILENO, &event);
assert(err == 0);
n = epoll_wait(epfd, events, 1, -1);
assert(n > 0);
if (epoll_ctl(epfd, EPOLL_CTL_MOD, STDOUT_FILENO, &event) != 0) {
perror("EPOLL_CTL_MOD failed");
exit(EXIT_FAILURE);
}
n = epoll_wait(epfd, events, 1, -1);
assert(n > 0);
if (epoll_ctl(epfd, EPOLL_CTL_DEL, STDOUT_FILENO, &event) != 0) {
perror("EPOLL_CTL_DEL failed");
exit(EXIT_FAILURE);
}
printf("ok\n");
return (EXIT_SUCCESS);
}