summaryrefslogtreecommitdiffstats
path: root/c/src/exec/posix/src/psignal.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1996-06-07 13:54:23 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1996-06-07 13:54:23 +0000
commit895efd9edc7f20e6d7e7599949e5a4e987a3ff7f (patch)
tree9f52b9f66ea43046f4c0552a5aa009e96edb656f /c/src/exec/posix/src/psignal.c
parentin newlib now (diff)
downloadrtems-895efd9edc7f20e6d7e7599949e5a4e987a3ff7f.tar.bz2
key destructor is now run at correct point in pthread_exit() sequence and
should be correct for other apis as well. missing page numbers added on some references. initial attempt at sig_procmask() and pthread_sigmask().
Diffstat (limited to 'c/src/exec/posix/src/psignal.c')
-rw-r--r--c/src/exec/posix/src/psignal.c142
1 files changed, 104 insertions, 38 deletions
diff --git a/c/src/exec/posix/src/psignal.c b/c/src/exec/posix/src/psignal.c
index b0c79b9589..7988e800e5 100644
--- a/c/src/exec/posix/src/psignal.c
+++ b/c/src/exec/posix/src/psignal.c
@@ -8,40 +8,36 @@
#include <rtems/system.h>
#include <rtems/score/thread.h>
+#include <rtems/posix/seterr.h>
+#include <rtems/posix/threadsup.h>
/*
- * Currently only 20 signals numbered 1-20 are defined
+ * Currently 32 signals numbered 1-32 are defined
*/
-#define SIGNAL_ALL_MASK 0x000fffff
+#define SIGNAL_EMPTY_MASK 0x00000000
+#define SIGNAL_ALL_MASK 0xffffffff
#define signo_to_mask( _sig ) (1 << ((_sig) - 1))
#define is_valid_signo( _sig ) \
((signo_to_mask(_sig) & SIGNAL_ALL_MASK) != 0 )
-/*
- * 3.3.2 Send a Signal to a Process, P1003.1b-1993, p. 68
+/*** PROCESS WIDE STUFF ****/
+
+sigset_t _POSIX_signals_Blocked = SIGNAL_EMPTY_MASK;
+sigset_t _POSIX_signals_Pending = SIGNAL_EMPTY_MASK;
+
+struct sigaction _POSIX_signals_Vectors[ SIGRTMAX ];
+
+/*PAGE
*
- * NOTE: Behavior of kill() depends on _POSIX_SAVED_IDS.
+ * _POSIX_signals_Manager_Initialization
*/
-int kill(
- pid_t pid,
- int sig
-)
+void _POSIX_signals_Manager_Initialization( void )
{
- /*
- * Only supported for the "calling process" (i.e. this node).
- */
-
- assert( pid == getpid() );
-
- /* SIGABRT comes from abort via assert */
- if ( sig == SIGABRT ) {
- exit( 1 );
- }
- return POSIX_NOT_IMPLEMENTED();
+ /* XXX install default actions for all vectors */
}
/*
@@ -52,7 +48,8 @@ int sigemptyset(
sigset_t *set
)
{
- assert( set ); /* no word from posix, solaris returns EFAULT */
+ if ( !set )
+ set_errno_and_return_minus_one( EFAULT );
*set = 0;
return 0;
@@ -66,7 +63,8 @@ int sigfillset(
sigset_t *set
)
{
- assert( set );
+ if ( !set )
+ set_errno_and_return_minus_one( EFAULT );
*set = SIGNAL_ALL_MASK;
return 0;
@@ -81,12 +79,11 @@ int sigaddset(
int signo
)
{
- assert( set );
+ if ( !set )
+ set_errno_and_return_minus_one( EFAULT );
- if ( !is_valid_signo(signo) ) {
- errno = EINVAL;
- return -1;
- }
+ if ( !is_valid_signo(signo) )
+ set_errno_and_return_minus_one( EINVAL );
*set |= signo_to_mask(signo);
return 0;
@@ -101,12 +98,11 @@ int sigdelset(
int signo
)
{
- assert( set );
+ if ( !set )
+ set_errno_and_return_minus_one( EFAULT );
- if ( !is_valid_signo(signo) ) {
- errno = EINVAL;
- return -1;
- }
+ if ( !is_valid_signo(signo) )
+ set_errno_and_return_minus_one( EINVAL );
*set &= ~signo_to_mask(signo);
return 0;
@@ -121,12 +117,11 @@ int sigismember(
int signo
)
{
- assert( set );
+ if ( !set )
+ set_errno_and_return_minus_one( EFAULT );
- if ( !is_valid_signo(signo) ) {
- errno = EINVAL;
- return -1;
- }
+ if ( !is_valid_signo(signo) )
+ set_errno_and_return_minus_one( EINVAL );
if ( *set & signo_to_mask(signo) )
return 1;
@@ -144,6 +139,19 @@ int sigaction(
struct sigaction *oact
)
{
+ if ( !act )
+ set_errno_and_return_minus_one( EFAULT );
+
+ if ( !is_valid_signo(sig) )
+ set_errno_and_return_minus_one( EINVAL );
+
+ if ( oact )
+ *oact = _POSIX_signals_Vectors[ sig ];
+
+ /* XXX need to interpret some stuff here */
+
+ _POSIX_signals_Vectors[ sig ] = *act;
+
return POSIX_NOT_IMPLEMENTED();
}
@@ -151,6 +159,7 @@ int sigaction(
* 3.3.5 Examine and Change Blocked Signals, P1003.1b-1993, p. 73
*
* NOTE: P1003.1c/D10, p. 37 adds pthread_sigmask().
+ *
*/
int sigprocmask(
@@ -159,7 +168,11 @@ int sigprocmask(
sigset_t *oset
)
{
- return POSIX_NOT_IMPLEMENTED();
+ /*
+ * P1003.1c/Draft 10, p. 38 maps sigprocmask to pthread_sigmask.
+ */
+
+ return pthread_sigmask( how, set, oset );
}
/*
@@ -174,6 +187,35 @@ int pthread_sigmask(
sigset_t *oset
)
{
+ POSIX_API_Control *api;
+
+ if ( !set && !oset )
+ set_errno_and_return_minus_one( EFAULT );
+
+ api = _Thread_Executing->API_Extensions[ THREAD_API_POSIX ];
+
+ if ( oset )
+ *oset = api->signals_blocked;
+
+ if ( !set )
+ set_errno_and_return_minus_one( EFAULT );
+
+ switch ( how ) {
+ case SIG_BLOCK:
+ api->signals_blocked |= *set;
+ break;
+ case SIG_UNBLOCK:
+ api->signals_blocked &= ~*set;
+ break;
+ case SIG_SETMASK:
+ api->signals_blocked = *set;
+ break;
+ default:
+ set_errno_and_return_minus_one( EINVAL );
+ }
+
+ /* XXX evaluate the new set */
+
return POSIX_NOT_IMPLEMENTED();
}
@@ -256,6 +298,30 @@ int sigqueue(
}
/*
+ * 3.3.2 Send a Signal to a Process, P1003.1b-1993, p. 68
+ *
+ * NOTE: Behavior of kill() depends on _POSIX_SAVED_IDS.
+ */
+
+int kill(
+ pid_t pid,
+ int sig
+)
+{
+ /*
+ * Only supported for the "calling process" (i.e. this node).
+ */
+
+ assert( pid == getpid() );
+
+ /* SIGABRT comes from abort via assert */
+ if ( sig == SIGABRT ) {
+ exit( 1 );
+ }
+ return POSIX_NOT_IMPLEMENTED();
+}
+
+/*
* 3.3.10 Send a Signal to a Thread, P1003.1c/D10, p. 43
*/