Fix race in spawn.signal_stress test

The default behavior for a real-time signal is to terminate the process.
If the child we fork sends a SIGRTMIN signal before we've set up the
ScopedSignalHandler for it, then the parent is terminated.

Test: adb shell /data/nativetest64/bionic-unit-tests-static/bionic-unit-tests-static --gtest_filter=spawn.signal_stress --gtest_repeat=1000
Bug: b/77554047
Change-Id: Ib44cbea8ccf506644405d8f426d9ad24e77cfa33
diff --git a/tests/spawn_test.cpp b/tests/spawn_test.cpp
index 86175f9..7e45ec3 100644
--- a/tests/spawn_test.cpp
+++ b/tests/spawn_test.cpp
@@ -433,12 +433,12 @@
   static pid_t parent = getpid();
 
   setpgid(0, 0);
+  signal(SIGRTMIN, SIG_IGN);
 
   pid_t pid = fork();
   ASSERT_NE(-1, pid);
 
   if (pid == 0) {
-    signal(SIGRTMIN, SIG_IGN);
     for (size_t i = 0; i < 1024; ++i) {
       kill(0, SIGRTMIN);
       usleep(10);