summaryrefslogtreecommitdiff
path: root/test-skeleton.c
diff options
context:
space:
mode:
authorTulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>2015-06-02 10:32:25 -0300
committerTulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>2015-06-05 09:39:49 -0300
commit02242448bf431a69fd0b8c929ca4408a05479baa (patch)
tree2e551395d222ce28952c9fcc48bc409bdf1f5c0b /test-skeleton.c
parent7fe9e2e089f4990b7d18d0798f591ab276b15f2b (diff)
downloadglibc-02242448bf431a69fd0b8c929ca4408a05479baa.tar.gz
Avoid outputting to TTY after an expected memory corruption in testcase
Protect TTY against an expected memory corruption from testcase tst-malloc-backtrace, which is expected to SIGABRT after a forced memory corruption.
Diffstat (limited to 'test-skeleton.c')
-rw-r--r--test-skeleton.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/test-skeleton.c b/test-skeleton.c
index 1332c94a86..9ee5001440 100644
--- a/test-skeleton.c
+++ b/test-skeleton.c
@@ -218,6 +218,22 @@ signal_handler (int sig __attribute__ ((unused)))
exit (1);
}
+/* Avoid all the buffer overflow messages on stderr. */
+static void
+__attribute__ ((unused))
+ignore_stderr (void)
+{
+ int fd = open (_PATH_DEVNULL, O_WRONLY);
+ if (fd == -1)
+ close (STDERR_FILENO);
+ else
+ {
+ dup2 (fd, STDERR_FILENO);
+ close (fd);
+ }
+ setenv ("LIBC_FATAL_STDERR_", "1", 1);
+}
+
/* Set fortification error handler. Used when tests want to verify that bad
code is caught by the library. */
static void
@@ -231,17 +247,7 @@ set_fortify_handler (void (*handler) (int sig))
sigemptyset (&sa.sa_mask);
sigaction (SIGABRT, &sa, NULL);
-
- /* Avoid all the buffer overflow messages on stderr. */
- int fd = open (_PATH_DEVNULL, O_WRONLY);
- if (fd == -1)
- close (STDERR_FILENO);
- else
- {
- dup2 (fd, STDERR_FILENO);
- close (fd);
- }
- setenv ("LIBC_FATAL_STDERR_", "1", 1);
+ ignore_stderr ();
}
/* We provide the entry point here. */