1 #include <darwintest.h>
3 #include <sys/socket.h>
6 T_DECL(socket_poll_close_25786011
, "Tests an invalid poll call to a socket and then calling close.", T_META_LTEPHASE(LTE_POSTINIT
))
10 my_socket
= socket(PF_LOCAL
, SOCK_STREAM
, 0);
11 T_WITH_ERRNO
; T_ASSERT_TRUE(my_socket
> 0, "create socket");
14 * Setup a pollfd that we know will return an error when we try
15 * to create a knote for it. We specify a BSD vnode specific event
18 struct pollfd my_pollfd
= {
24 * Previously the call to kevent_register() in the kernel from this call
25 * would leak an iocount reference on the fileproc, which would cause any
26 * subsequent calls to close() on the associated fd to block indefinitely.
28 ret
= poll(&my_pollfd
, 1, 0);
29 T_WITH_ERRNO
; T_ASSERT_TRUE(ret
== 1, "poll returned %d", ret
);
31 ret
= close(my_socket
);
32 T_ASSERT_POSIX_ZERO(ret
, "close on socket with fd %d\n", my_socket
);
34 T_PASS("socket_poll_close_25786011 PASSED");