From 2d7ccae46bd0400a674ec363ac5f39abe7f1e921 Mon Sep 17 00:00:00 2001
From: Sehrope Sarkuni <sehrope@jackdb.com>
Date: Wed, 10 Jun 2026 09:32:14 -0400
Subject: [PATCH 2/4] 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 4b84f86e7d7..4acee17f382 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.48.1

