From 838c698517544fcc4fdcc7a2536a915327354569 Mon Sep 17 00:00:00 2001
From: Sehrope Sarkuni <sehrope@jackdb.com>
Date: Wed, 10 Jun 2026 09:32:14 -0400
Subject: [PATCH] Fix CreateThread failure check in pg_test_fsync

CreateThread returns NULL on failure, not INVALID_HANDLE_VALUE, so
the error branch could never fire.
---
 src/bin/pg_test_fsync/pg_test_fsync.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/bin/pg_test_fsync/pg_test_fsync.c b/src/bin/pg_test_fsync/pg_test_fsync.c
index c51b1271f1f..39d0792614d 100644
--- a/src/bin/pg_test_fsync/pg_test_fsync.c
+++ b/src/bin/pg_test_fsync/pg_test_fsync.c
@@ -50,8 +50,7 @@ do { \
 #define START_TIMER \
 do { \
 	alarm_triggered = false; \
-	if (CreateThread(NULL, 0, process_alarm, NULL, 0, NULL) == \
-		INVALID_HANDLE_VALUE) \
+	if (CreateThread(NULL, 0, process_alarm, NULL, 0, NULL) == NULL) \
 		pg_fatal("could not create thread for alarm"); \
 	gettimeofday(&start_t, NULL); \
 } while (0)
-- 
2.53.0.windows.2

