Update tst_sig.c to use tst_setup_signal() to setup signals than
varying versions of signal().
Change "Linux Torvalds" to "Linus Torvalds" in CREDITS.
diff --git a/CREDITS b/CREDITS
index 7a6c730..1d6df6b 100644
--- a/CREDITS
+++ b/CREDITS
@@ -1,4 +1,4 @@
-This is an attempt at a credits-file in the style begun by Linux
+This is an attempt at a credits-file in the style begun by Linus
Torvalds and the Linux project. It is sorted by name and formatted
to allow easy grepping and beautification by scripts. The fields
are: name (N), email (E), web-address (W), PGP key ID and
diff --git a/lib/tst_sig.c b/lib/tst_sig.c
index 2495368..8f17d36 100644
--- a/lib/tst_sig.c
+++ b/lib/tst_sig.c
@@ -30,7 +30,7 @@
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
*/
-/* $Id: tst_sig.c,v 1.2 2000/08/30 18:43:38 nstraz Exp $ */
+/* $Id: tst_sig.c,v 1.3 2000/09/07 14:34:44 alaffin Exp $ */
/*****************************************************************************
OS Testing - Silicon Graphics, Inc.
@@ -67,10 +67,6 @@
***************************************************************************/
-#ifndef CRAY
-#define _BSD_SIGNALS 1 /* Specify that we are using BSD signal interface */
-#endif
-
#include <errno.h>
#include <string.h>
#include <signal.h>
@@ -82,6 +78,7 @@
extern int errno;
static void def_handler(); /* default signal handler */
+static void (*tst_setup_signal( int, void (*)(int)))(int);
/****************************************************************************
* tst_sig() : set-up to catch unexpected signals. fork_flag is set to NOFORK
@@ -158,7 +155,7 @@
continue;
default:
- if (signal(sig, handler) == SIG_ERR) {
+ if (tst_setup_signal(sig, handler) == SIG_ERR) {
(void) sprintf(mesg,
"signal() failed for signal %d. error:%d %s.",
sig, errno, strerror(errno));
@@ -185,24 +182,11 @@
static void
def_handler(int sig)
{
- char mesg[MAXMESG]; /* holds tst_res message */
-
- /* first reset trap for this signal (except SIGCLD - its weird) */
- if ((sig != SIGCLD) && (sig != SIGSTOP) && (sig != SIGCONT)) {
- if (signal(sig, def_handler) == SIG_ERR) {
- (void) sprintf(mesg,
- "def_handler: signal() failed for signal %d. error:%d %s.",
- sig, errno, strerror(errno));
- tst_resm(TWARN, mesg);
- }
- }
-
- (void) sprintf(mesg, "Unexpected signal %d received.", sig);
/*
* Break remaining test cases, do any cleanup, then exit
*/
- tst_brkm(TBROK, 0, mesg);
+ tst_brkm(TBROK, 0, "Unexpected signal %d received.", sig);
/* now cleanup and exit */
if (T_cleanup) {
@@ -211,3 +195,25 @@
tst_exit();
}
+
+/*
+ * tst_setup_signal - A function like signal(), but we have
+ * control over its personality.
+ */
+static void (*tst_setup_signal( int sig, void (*handler)(int)))(int)
+{
+ struct sigaction my_act,old_act;
+ int ret;
+
+ my_act.sa_handler = handler;
+ my_act.sa_flags = SA_RESTART;
+ sigemptyset(&my_act.sa_mask);
+
+ ret = sigaction(sig, &my_act, &old_act);
+
+ if ( ret == 0 )
+ return( old_act.sa_handler );
+ else
+ return( SIG_ERR );
+}
+