Use signal-safe functions in signal handler
authorPeter Eisentraut <[email protected]>
Wed, 6 Dec 2023 09:11:36 +0000 (10:11 +0100)
committerPeter Eisentraut <[email protected]>
Wed, 6 Dec 2023 09:11:36 +0000 (10:11 +0100)
According to signal-safety(7), exit(3) and puts(3) are not safe to call
in a signal handler.

Author: Tristan Partin <[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/CTVDKVZCCVSY.1XQ87UL50KQRD%40gonk

src/bin/pg_test_fsync/pg_test_fsync.c

index f56e494f70fd8d04c86871eee89a0e3e77ff10ec..f109aa5717456c03e5f0386ad534ff4931b931bc 100644 (file)
@@ -602,8 +602,8 @@ signal_cleanup(SIGNAL_ARGS)
    if (needs_unlink)
        unlink(filename);
    /* Finish incomplete line on stdout */
-   puts("");
-   exit(1);
+   write(STDOUT_FILENO, "\n", 1);
+   _exit(1);
 }
 
 #ifdef HAVE_FSYNC_WRITETHROUGH