#include <limits.h>
#include <fcntl.h>
#include "ptrace.h"
-#include <setjmp.h>
#include <signal.h>
#include <sys/resource.h>
#include <sys/wait.h>
static void interrupt(int sig);
#ifdef HAVE_SIG_ATOMIC_T
-static volatile sig_atomic_t interrupted;
+static volatile sig_atomic_t interrupted, restart_failed;
#else
-static volatile int interrupted;
+static volatile int interrupted, restart_failed;
#endif
-static jmp_buf timer_jmp_buf;
static sigset_t timer_set;
static void timer_sighandler(int);
return TE_BREAK;
}
+ const bool unblock_delay_timer = is_delay_timer_created();
+
/*
* The window of opportunity to handle expirations
* of the delay timer opens here.
* Unblock the signal handler for the delay timer
* iff the delay timer is already created.
*/
- if (is_delay_timer_created()) {
- if (sigsetjmp(timer_jmp_buf, 1)) {
- /*
- * restart_delayed_tcbs() forwarded an error
- * from dispatch_event().
- */
- return TE_BREAK;
- }
+ if (unblock_delay_timer)
sigprocmask(SIG_UNBLOCK, &timer_set, NULL);
- }
/*
* If the delay timer has expired, then its expiration
* of the delay timer closes here.
*
* Block the signal handler for the delay timer
- * iff the delay timer is already created.
+ * iff it was unblocked earlier.
*/
- if (is_delay_timer_created())
+ if (unblock_delay_timer) {
sigprocmask(SIG_BLOCK, &timer_set, NULL);
+ if (restart_failed)
+ return TE_BREAK;
+ }
+
if (pid < 0) {
if (wait_errno == EINTR)
return TE_NEXT;
static void
timer_sighandler(int sig)
{
+ if (restart_failed)
+ return;
+
int saved_errno = errno;
if (!restart_delayed_tcbs())
- siglongjmp(timer_jmp_buf, 1);
+ restart_failed = 1;
errno = saved_errno;
}