aboutsummaryrefslogtreecommitdiff
path: root/tests/compat/pipe2.c
diff options
context:
space:
mode:
authorBrent Cook <busterb@gmail.com>2025-04-16 08:12:25 -0500
committerBrent Cook <busterb@gmail.com>2025-04-16 08:12:25 -0500
commit5d119ff7121493e25129c86a356fe2e78f20d9a9 (patch)
tree71a934c57484ed7885cd8fe0f92621218da78f39 /tests/compat/pipe2.c
parent9ba4b33d668230aa0c453f5c225dc93ccc007985 (diff)
parent6f7da782ec4ce17162b3c27d2b3d3e2faf208a97 (diff)
downloadportable-master.tar.gz
portable-master.tar.bz2
portable-master.zip
Land #1082, add tests for #1069HEADmaster
Ensure where sockets and file descriptors can overlap that the correct library calls are used on Windows.
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: