summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac37
-rw-r--r--misc.c2
2 files changed, 39 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 8adfcb347..e696ac751 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2500,6 +2500,43 @@ static void sighandler(int sig) { _exit(1); }
2500 ) 2500 )
2501fi 2501fi
2502 2502
2503AC_MSG_CHECKING([if SA_RESTARTed signals interrupt select()])
2504AC_RUN_IFELSE(
2505 [AC_LANG_PROGRAM([[
2506#ifdef HAVE_SYS_SELECT
2507# include <sys/select.h>
2508#endif
2509#include <sys/types.h>
2510#include <sys/time.h>
2511#include <stdlib.h>
2512#include <signal.h>
2513static void sighandler(int sig) { }
2514 ]], [[
2515 int r;
2516 pid_t pid;
2517 struct sigaction sa;
2518
2519 sa.sa_handler = sighandler;
2520 sa.sa_flags = SA_RESTART;
2521 (void)sigaction(SIGTERM, &sa, NULL);
2522 if ((pid = fork()) == 0) { /* child */
2523 sleep(1);
2524 kill(getppid(), SIGTERM);
2525 sleep(1);
2526 kill(getppid(), SIGKILL);
2527 exit(0);
2528 } else { /* parent */
2529 r = select(0, NULL, NULL, NULL, NULL);
2530 }
2531 exit(r == -1 ? 0 : 1);
2532 ]])],
2533 [AC_MSG_RESULT([yes])],
2534 [AC_MSG_RESULT([no])
2535 AC_DEFINE([NO_SA_RESTART], [1],
2536 [SA_RESTARTed signals do no interrupt select])],
2537 [AC_MSG_WARN([cross compiling: assuming yes])]
2538)
2539
2503AC_CHECK_FUNCS([getpgrp],[ 2540AC_CHECK_FUNCS([getpgrp],[
2504 AC_MSG_CHECKING([if getpgrp accepts zero args]) 2541 AC_MSG_CHECKING([if getpgrp accepts zero args])
2505 AC_COMPILE_IFELSE( 2542 AC_COMPILE_IFELSE(
diff --git a/misc.c b/misc.c
index 506507226..554ceb0b1 100644
--- a/misc.c
+++ b/misc.c
@@ -2258,8 +2258,10 @@ ssh_signal(int signum, sshsig_t handler)
2258 memset(&sa, 0, sizeof(sa)); 2258 memset(&sa, 0, sizeof(sa));
2259 sa.sa_handler = handler; 2259 sa.sa_handler = handler;
2260 sigfillset(&sa.sa_mask); 2260 sigfillset(&sa.sa_mask);
2261#if defined(SA_RESTART) && !defined(NO_SA_RESTART)
2261 if (signum != SIGALRM) 2262 if (signum != SIGALRM)
2262 sa.sa_flags = SA_RESTART; 2263 sa.sa_flags = SA_RESTART;
2264#endif
2263 if (sigaction(signum, &sa, &osa) == -1) { 2265 if (sigaction(signum, &sa, &osa) == -1) {
2264 debug3("sigaction(%s): %s", strsignal(signum), strerror(errno)); 2266 debug3("sigaction(%s): %s", strsignal(signum), strerror(errno));
2265 return SIG_ERR; 2267 return SIG_ERR;