From 0db66873874fdf3297cc211ba46de9dc6df6cbdb Mon Sep 17 00:00:00 2001 From: bcook Date: Wed, 9 Jul 2014 14:27:00 +0000 Subject: check if we were previously on a signal stack before restoring. OS X fails to restore the old signal stack because the signal stack is not enabled by default. This causes sigaltstack(2) to fail with ENOMEM as ss_size is 0, < MINSIGSTCKSZ. ok jsing@ --- regress/lib/libc/explicit_bzero/explicit_bzero.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'regress/lib/libc') diff --git a/regress/lib/libc/explicit_bzero/explicit_bzero.c b/regress/lib/libc/explicit_bzero/explicit_bzero.c index b4b6c9e559e..d78c4d60541 100644 --- a/regress/lib/libc/explicit_bzero/explicit_bzero.c +++ b/regress/lib/libc/explicit_bzero/explicit_bzero.c @@ -1,4 +1,4 @@ -/* $OpenBSD: explicit_bzero.c,v 1.1 2014/06/12 22:01:55 matthew Exp $ */ +/* $OpenBSD: explicit_bzero.c,v 1.2 2014/07/09 14:26:59 bcook Exp $ */ /* * Copyright (c) 2014 Google Inc. * @@ -67,7 +67,8 @@ call_on_stack(void (*fn)(int), void *stack, size_t stacklen) /* Restore the original signal action, stack, and mask. */ ASSERT_EQ(0, sigaction(SIGUSR1, &oldsigact, NULL)); - ASSERT_EQ(0, sigaltstack(&oldsigstk, NULL)); + if (oldsigstk.ss_flags & SA_ONSTACK) + ASSERT_EQ(0, sigaltstack(&oldsigstk, NULL)); ASSERT_EQ(0, sigprocmask(SIG_SETMASK, &oldsigset, NULL)); } -- cgit v1.2.3