diff options
author | Andy Getz <durandal@google.com> | 2020-04-04 18:05:30 -0400 |
---|---|---|
committer | Andy Getz <durandal@google.com> | 2020-04-04 18:05:30 -0400 |
commit | 7084afda5aa3d277177f11056c6e9776fd0a3d1c (patch) | |
tree | 0e57a733881ba76ae264c682e3c88c3a22f5329a | |
parent | c344cb5a8d2bea2a46dcf2805cdb859bb70fa6cb (diff) | |
parent | 08347d7a16044ea636465a2bbe13a5d15522e238 (diff) | |
download | googletest-7084afda5aa3d277177f11056c6e9776fd0a3d1c.tar.gz googletest-7084afda5aa3d277177f11056c6e9776fd0a3d1c.tar.bz2 googletest-7084afda5aa3d277177f11056c6e9776fd0a3d1c.zip |
Merge pull request #2762 from pkryger:avoid_sigprof
PiperOrigin-RevId: 304613137
-rw-r--r-- | googletest/test/googletest-death-test-test.cc | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/googletest/test/googletest-death-test-test.cc b/googletest/test/googletest-death-test-test.cc index cba906cc..b0dda27f 100644 --- a/googletest/test/googletest-death-test-test.cc +++ b/googletest/test/googletest-death-test-test.cc @@ -391,17 +391,19 @@ void SigprofAction(int, siginfo_t*, void*) { /* no op */ } // Sets SIGPROF action and ITIMER_PROF timer (interval: 1ms). void SetSigprofActionAndTimer() { - struct itimerval timer; - timer.it_interval.tv_sec = 0; - timer.it_interval.tv_usec = 1; - timer.it_value = timer.it_interval; - ASSERT_EQ(0, setitimer(ITIMER_PROF, &timer, nullptr)); struct sigaction signal_action; memset(&signal_action, 0, sizeof(signal_action)); sigemptyset(&signal_action.sa_mask); signal_action.sa_sigaction = SigprofAction; signal_action.sa_flags = SA_RESTART | SA_SIGINFO; ASSERT_EQ(0, sigaction(SIGPROF, &signal_action, nullptr)); + // timer comes second, to avoid SIGPROF premature delivery, as suggested at + // https://www.gnu.org/software/libc/manual/html_node/Setting-an-Alarm.html + struct itimerval timer; + timer.it_interval.tv_sec = 0; + timer.it_interval.tv_usec = 1; + timer.it_value = timer.it_interval; + ASSERT_EQ(0, setitimer(ITIMER_PROF, &timer, nullptr)); } // Disables ITIMER_PROF timer and ignores SIGPROF signal. |