FreeBSD/tests/sys/kqueue/main.c
/* Retrieve a single kevent, specifying a maximum time to wait for it. */
Retrieve a single kevent, specifying a maximum time to wait for it.
Retrieve a single kevent specifying a maximum time to wait for it .
struct kevent *
kevent_get_timeout(int kqfd, int seconds)
{
    int nfds;
    struct kevent *kev;
    struct timespec timeout = {seconds, 0};
    if ((kev = calloc(1, sizeof(*kev))) == NULL)
	err(1, "out of memory");
    nfds = kevent(kqfd, NULL, 0, kev, 1, &timeout);
    if (nfds < 0) {
        err(1, "kevent(2)");
    } else if (nfds == 0) {
        free(kev);
        kev = NULL;
    }
    return (kev);
}
struct kevent * kevent_get_timeout ( int kqfd , int seconds ) { int nfds ; struct kevent * kev ; struct timespec timeout = { seconds , 0 } ; if ( ( kev = calloc ( 1 , sizeof ( * kev ) ) ) == NULL ) err ( 1 , " " ) ; nfds = kevent ( kqfd , NULL , 0 , kev , 1 , & timeout ) ; if ( nfds < 0 ) { err ( 1 , " " ) ; } else if ( nfds == 0 ) { free ( kev ) ; kev = NULL ; } return ( kev ) ; }
Retrieve a single kevent, specifying a maximum time to wait for it.
Retrieve a single kevent specifying a maximum time to wait for it .