* src/utils.c (run_with_timeout): Set SIGALRM handler before setjmp() (reported by valgrind)

This commit is contained in:
Tim Rühsen 2024-05-05 16:42:49 +02:00
parent 5fe01167d1
commit a582633c97

View File

@ -2176,16 +2176,16 @@ run_with_timeout (double timeout, void (*fun) (void *), void *arg)
return false; return false;
} }
/* Set alarm handler before doing setjmp. */
signal (SIGALRM, abort_run_with_timeout);
if (SETJMP (run_with_timeout_env) != 0) if (SETJMP (run_with_timeout_env) != 0)
{ {
/* Longjumped out of FUN with a timeout. */ /* Longjumped out of FUN with a timeout. */
signal (SIGALRM, SIG_DFL); signal (SIGALRM, SIG_DFL);
return true; return true;
} }
else
{
signal (SIGALRM, abort_run_with_timeout);
}
alarm_set (timeout); alarm_set (timeout);
fun (arg); fun (arg);