1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-06-02 22:57:34 +02:00

Use dup2() to redirect stderr in the common/error unit test.

The assignment was obviously not kosher but seemed fine for a test in short-lived fork. However, musl libc defines stderr as read-only so this trick won't work.

Instead use dup2(), which is pretty clearly the correct way to do this.
This commit is contained in:
David Steele 2025-05-26 12:49:47 -04:00
parent 8737cad566
commit b5a26d99a0

View File

@ -416,7 +416,7 @@ testRun(void)
HRN_FORK_CHILD_BEGIN(.expectedExitStatus = UnhandledError.code)
{
// Redirect stderr to stdout (we do not care about the output here since coverage will tell us we hit the code)
stderr = stdout;
dup2(fileno(stdout), fileno(stderr));
THROW(TestChildError, "does not get caught!");
}