aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/compat/pipe2.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/compat/pipe2.c b/tests/compat/pipe2.c
index 7600783..c27a858 100644
--- a/tests/compat/pipe2.c
+++ b/tests/compat/pipe2.c
@@ -35,6 +35,22 @@ static int setfl(int fd, int flag)
35 return rc; 35 return rc;
36} 36}
37 37
38/*
39 * Have open() temporarily use up file descriptors until reaching beyond the
40 * allocated sockets, then leak the ones conflicting with any of the latter.
41 */
42static void create_issue_1069_sentinels(int socket_vector[2])
43{
44 int fd = open("CONIN$", O_RDONLY);
45 if (fd == -1 || fd > socket_vector[0] && fd > socket_vector[1]) {
46 return;
47 }
48 create_issue_1069_sentinels(socket_vector);
49 if (fd != socket_vector[0] && fd != socket_vector[1]) {
50 close(fd);
51 }
52}
53
38int socketpair(int domain, int type, int protocol, int socket_vector[2]) 54int socketpair(int domain, int type, int protocol, int socket_vector[2])
39{ 55{
40 if (domain != AF_UNIX || !(type & SOCK_STREAM) || protocol != PF_UNSPEC) 56 if (domain != AF_UNIX || !(type & SOCK_STREAM) || protocol != PF_UNSPEC)
@@ -85,6 +101,9 @@ int socketpair(int domain, int type, int protocol, int socket_vector[2])
85 goto err; 101 goto err;
86 102
87 closesocket(listener); 103 closesocket(listener);
104
105 create_issue_1069_sentinels(socket_vector);
106
88 return 0; 107 return 0;
89 108
90err: 109err: