summaryrefslogtreecommitdiffstats
path: root/cpukit/posix
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1999-07-01 22:28:30 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1999-07-01 22:28:30 +0000
commit51e04a2c7f4e42e471f123b0e801bf3b7e26750f (patch)
tree885a698bad049a7a63c3ff7813f2f827a4270595 /cpukit/posix
parentModified to reflect change in calling sequence of mount(). (diff)
downloadrtems-51e04a2c7f4e42e471f123b0e801bf3b7e26750f.tar.bz2
New file to implement signal(2).
Diffstat (limited to 'cpukit/posix')
-rw-r--r--cpukit/posix/src/signal_2.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/cpukit/posix/src/signal_2.c b/cpukit/posix/src/signal_2.c
new file mode 100644
index 0000000000..d3931ef362
--- /dev/null
+++ b/cpukit/posix/src/signal_2.c
@@ -0,0 +1,50 @@
+/*
+ * signal(2) - Install signal handler
+ *
+ * COPYRIGHT (c) 1989-1998.
+ * On-Line Applications Research Corporation (OAR).
+ * Copyright assigned to U.S. Government, 1994.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+
+
+#include <signal.h>
+#include <errno.h>
+
+typedef void (*sighandler_t)(int);
+
+sighandler_t signal(
+ int signum,
+ sighandler_t handler
+)
+{
+ struct sigaction s;
+ struct sigaction old;
+
+ s.sa_handler = handler ;
+ sigemptyset(&s.sa_mask);
+
+ /*
+ * Depending on which system we want to behave like, one of
+ * the following versions should be chosen.
+ */
+
+/* #define signal_like_linux */
+
+#if defined(signal_like_linux)
+ s.sa_flags = SA_RESTART | SA_INTERRUPT | SA_NOMASK;
+ s.sa_restorer= NULL ;
+#elif defined(signal_like_SVR4)
+ s.sa_flags = SA_RESTART;
+#else
+ s.sa_flags = 0;
+#endif
+
+ sigaction( signum, &s, &old );
+ return (sighandler_t) old.sa_handler;
+}