Skip to content

Commit d3e2ac4

Browse files
committed
Restore existing signal timer after upstream backoff regression
1 parent 7bd635a commit d3e2ac4

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎tests/test_subprocess.c‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,21 +218,27 @@ TEST(subprocess_spawn_backoff_resumes_after_eintr) {
218218
.it_interval = {.tv_sec = 0, .tv_usec = 1000},
219219
.it_value = {.tv_sec = 0, .tv_usec = 1000},
220220
};
221+
struct itimerval previous_timer = {0};
221222
g_spawn_backoff_alarm_count = 0;
222-
bool timer_started = handler_installed && setitimer(ITIMER_REAL, &timer, NULL) == 0;
223+
bool timer_started = handler_installed && setitimer(ITIMER_REAL, &timer, &previous_timer) == 0;
223224

224225
uint64_t started_at = cbm_now_ms();
225226
cbm_subprocess_force_spawn_eagain_for_testing(3);
226227
cbm_proc_result_t result = run_sh("exit 0", 0);
227228
uint64_t elapsed_ms = cbm_now_ms() - started_at;
228229

229230
struct itimerval disabled = {0};
230-
(void)setitimer(ITIMER_REAL, &disabled, NULL);
231+
if (timer_started) {
232+
(void)setitimer(ITIMER_REAL, &disabled, NULL);
233+
}
231234
if (handler_installed) {
232235
(void)sigaction(SIGALRM, &previous_action, NULL);
233236
}
234237

238+
bool timer_restored = !timer_started || setitimer(ITIMER_REAL, &previous_timer, NULL) == 0;
239+
235240
ASSERT_TRUE(handler_installed);
241+
ASSERT_TRUE(timer_restored);
236242
ASSERT_TRUE(timer_started);
237243
ASSERT_TRUE(g_spawn_backoff_alarm_count > 0);
238244
ASSERT_TRUE(elapsed_ms >= 50);

0 commit comments

Comments
 (0)