aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKartik Naik <kartik@bugqore.com>2026-08-11 23:13:36 +0530
committerKartik Naik <kartik@bugqore.com>2026-08-11 23:13:36 +0530
commitebdedf67ea07b3e4193d446179970b74764eab0b (patch)
tree6d5c2ace2b07d0f7abf81fbb5cb24b7cfefba7eb /tests
parent2aaf4dbee62926f4b3149d2fd6e2d40b2f6e1dd0 (diff)
downloadportable-ebdedf67ea07b3e4193d446179970b74764eab0b.tar.gz
portable-ebdedf67ea07b3e4193d446179970b74764eab0b.tar.bz2
portable-ebdedf67ea07b3e4193d446179970b74764eab0b.zip
set cloexec on the socket handle in win32 socketpair setfd
Diffstat (limited to 'tests')
-rw-r--r--tests/compat/pipe2.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/tests/compat/pipe2.c b/tests/compat/pipe2.c
index c0189db..3e79575 100644
--- a/tests/compat/pipe2.c
+++ b/tests/compat/pipe2.c
@@ -18,9 +18,10 @@ static int setfd(int fd, int flag)
18{ 18{
19 int rc = -1; 19 int rc = -1;
20 if (flag & FD_CLOEXEC) { 20 if (flag & FD_CLOEXEC) {
21 HANDLE h = (HANDLE)_get_osfhandle(fd); 21 /* fd is a Winsock SOCKET, not a CRT descriptor: use it as a
22 if (h != NULL) 22 * handle directly rather than translating with _get_osfhandle. */
23 rc = SetHandleInformation(h, HANDLE_FLAG_INHERIT, 0) == 0 ? -1 : 0; 23 HANDLE h = (HANDLE)(LONG_PTR)fd;
24 rc = SetHandleInformation(h, HANDLE_FLAG_INHERIT, 0) == 0 ? -1 : 0;
24 } 25 }
25 return rc; 26 return rc;
26} 27}