aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/generic
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/generic')
-rw-r--r--sysdeps/generic/segfault.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/sysdeps/generic/segfault.c b/sysdeps/generic/segfault.c
index 5a9e64a105..b0778df6fc 100644
--- a/sysdeps/generic/segfault.c
+++ b/sysdeps/generic/segfault.c
@@ -163,6 +163,23 @@ install_handler (void)
sigemptyset (&sa.sa_mask);
sa.sa_flags = SA_RESTART;
+ /* Maybe we are expected to use an alternative stack. */
+ if (getenv ("SEGFAULT_USE_ALTSTACK") != 0)
+ {
+ void *stack_mem = malloc (2 * SIGSTKSZ);
+ struct sigaltstack ss;
+
+ if (stack_mem != NULL)
+ {
+ ss.ss_sp = stack_mem;
+ ss.ss_flags = 0;
+ ss.ss_size = 2 * SIGSTKSZ;
+
+ if (sigaltstack (&ss, NULL) == 0)
+ sa.sa_flags |= SA_ONSTACK;
+ }
+ }
+
if (sigs == NULL)
sigaction (SIGSEGV, &sa, NULL);
else if (sigs[0] == '\0')
@@ -191,20 +208,4 @@ install_handler (void)
INSTALL_FOR_SIG (SIGABRT, "abrt");
INSTALL_FOR_SIG (SIGFPE, "fpe");
}
-
- /* Maybe we are expected to use an alternative stack. */
- if (getenv ("SEGFAULT_USE_ALTSTACK") != 0)
- {
- void *stack_mem = malloc (2 * SIGSTKSZ);
- struct sigaltstack ss;
-
- if (stack_mem != NULL)
- {
- ss.ss_sp = stack_mem;
- ss.ss_flags = SS_ONSTACK;
- ss.ss_size = 2 * SIGSTKSZ;
-
- sigaltstack (&ss, NULL);
- }
- }
}