summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorjb <jb@FreeBSD.org>1998-06-05 23:31:55 +0000
committerjb <jb@FreeBSD.org>1998-06-05 23:31:55 +0000
commit231ebf2d6ff646de62d346a4c426948c14f36499 (patch)
tree5e04b1e5e69d516f655706370cfca55d9458ee9c /lib
parent026f5fa529281f6b9a9727f4665fbb6c10a545a0 (diff)
downloadFreeBSD-src-231ebf2d6ff646de62d346a4c426948c14f36499.zip
FreeBSD-src-231ebf2d6ff646de62d346a4c426948c14f36499.tar.gz
Fix the signal behaviour for internal states which set the thread
state to running despite the SA_RESTART flag which is really just for syscalls.
Diffstat (limited to 'lib')
-rw-r--r--lib/libc_r/uthread/uthread_sig.c57
-rw-r--r--lib/libkse/thread/thr_sig.c57
-rw-r--r--lib/libpthread/thread/thr_sig.c57
3 files changed, 153 insertions, 18 deletions
diff --git a/lib/libc_r/uthread/uthread_sig.c b/lib/libc_r/uthread/uthread_sig.c
index 3fa3c56..58d8e9d 100644
--- a/lib/libc_r/uthread/uthread_sig.c
+++ b/lib/libc_r/uthread/uthread_sig.c
@@ -242,14 +242,59 @@ _thread_signal(pthread_t pthread, int sig)
*/
sigaddset(&pthread->sigpend,sig);
- /* Check if the thread is waiting on a child process: */
- if (sig == SIGCHLD && pthread->state == PS_WAIT_WAIT) {
- /* Change the state of the thread to run: */
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
-
/* Check if system calls are not restarted: */
- } else if ((_thread_sigact[sig - 1].sa_flags & SA_RESTART) == 0) {
+ if ((_thread_sigact[sig - 1].sa_flags & SA_RESTART) == 0) {
+ /*
+ * Process according to thread state:
+ */
+ switch (pthread->state) {
+ /*
+ * States which do not change when a signal is trapped:
+ */
+ case PS_COND_WAIT:
+ case PS_DEAD:
+ case PS_FDLR_WAIT:
+ case PS_FDLW_WAIT:
+ case PS_FILE_WAIT:
+ case PS_JOIN:
+ case PS_MUTEX_WAIT:
+ case PS_RUNNING:
+ case PS_STATE_MAX:
+ case PS_SIGTHREAD:
+ case PS_SUSPENDED:
+ /* Nothing to do here. */
+ break;
+
+ /*
+ * System calls that are restarted when interrupted by
+ * a signal:
+ */
+ case PS_FDR_WAIT:
+ case PS_FDW_WAIT:
+ case PS_SELECT_WAIT:
+ break;
+
+ /*
+ * States that are interrupted by the occurrence of a signal
+ * other than the scheduling alarm:
+ */
+ case PS_SLEEP_WAIT:
+ case PS_SIGWAIT:
+ case PS_WAIT_WAIT:
+ /* Flag the operation as interrupted: */
+ pthread->interrupted = 1;
+
+ /* Change the state of the thread to run: */
+ PTHREAD_NEW_STATE(pthread,PS_RUNNING);
+
+ /* Return the signal number: */
+ pthread->signo = sig;
+ break;
+ }
+ } else {
/*
+ * System calls are flagged for restart.
+ *
* Process according to thread state:
*/
switch (pthread->state) {
diff --git a/lib/libkse/thread/thr_sig.c b/lib/libkse/thread/thr_sig.c
index 3fa3c56..58d8e9d 100644
--- a/lib/libkse/thread/thr_sig.c
+++ b/lib/libkse/thread/thr_sig.c
@@ -242,14 +242,59 @@ _thread_signal(pthread_t pthread, int sig)
*/
sigaddset(&pthread->sigpend,sig);
- /* Check if the thread is waiting on a child process: */
- if (sig == SIGCHLD && pthread->state == PS_WAIT_WAIT) {
- /* Change the state of the thread to run: */
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
-
/* Check if system calls are not restarted: */
- } else if ((_thread_sigact[sig - 1].sa_flags & SA_RESTART) == 0) {
+ if ((_thread_sigact[sig - 1].sa_flags & SA_RESTART) == 0) {
+ /*
+ * Process according to thread state:
+ */
+ switch (pthread->state) {
+ /*
+ * States which do not change when a signal is trapped:
+ */
+ case PS_COND_WAIT:
+ case PS_DEAD:
+ case PS_FDLR_WAIT:
+ case PS_FDLW_WAIT:
+ case PS_FILE_WAIT:
+ case PS_JOIN:
+ case PS_MUTEX_WAIT:
+ case PS_RUNNING:
+ case PS_STATE_MAX:
+ case PS_SIGTHREAD:
+ case PS_SUSPENDED:
+ /* Nothing to do here. */
+ break;
+
+ /*
+ * System calls that are restarted when interrupted by
+ * a signal:
+ */
+ case PS_FDR_WAIT:
+ case PS_FDW_WAIT:
+ case PS_SELECT_WAIT:
+ break;
+
+ /*
+ * States that are interrupted by the occurrence of a signal
+ * other than the scheduling alarm:
+ */
+ case PS_SLEEP_WAIT:
+ case PS_SIGWAIT:
+ case PS_WAIT_WAIT:
+ /* Flag the operation as interrupted: */
+ pthread->interrupted = 1;
+
+ /* Change the state of the thread to run: */
+ PTHREAD_NEW_STATE(pthread,PS_RUNNING);
+
+ /* Return the signal number: */
+ pthread->signo = sig;
+ break;
+ }
+ } else {
/*
+ * System calls are flagged for restart.
+ *
* Process according to thread state:
*/
switch (pthread->state) {
diff --git a/lib/libpthread/thread/thr_sig.c b/lib/libpthread/thread/thr_sig.c
index 3fa3c56..58d8e9d 100644
--- a/lib/libpthread/thread/thr_sig.c
+++ b/lib/libpthread/thread/thr_sig.c
@@ -242,14 +242,59 @@ _thread_signal(pthread_t pthread, int sig)
*/
sigaddset(&pthread->sigpend,sig);
- /* Check if the thread is waiting on a child process: */
- if (sig == SIGCHLD && pthread->state == PS_WAIT_WAIT) {
- /* Change the state of the thread to run: */
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
-
/* Check if system calls are not restarted: */
- } else if ((_thread_sigact[sig - 1].sa_flags & SA_RESTART) == 0) {
+ if ((_thread_sigact[sig - 1].sa_flags & SA_RESTART) == 0) {
+ /*
+ * Process according to thread state:
+ */
+ switch (pthread->state) {
+ /*
+ * States which do not change when a signal is trapped:
+ */
+ case PS_COND_WAIT:
+ case PS_DEAD:
+ case PS_FDLR_WAIT:
+ case PS_FDLW_WAIT:
+ case PS_FILE_WAIT:
+ case PS_JOIN:
+ case PS_MUTEX_WAIT:
+ case PS_RUNNING:
+ case PS_STATE_MAX:
+ case PS_SIGTHREAD:
+ case PS_SUSPENDED:
+ /* Nothing to do here. */
+ break;
+
+ /*
+ * System calls that are restarted when interrupted by
+ * a signal:
+ */
+ case PS_FDR_WAIT:
+ case PS_FDW_WAIT:
+ case PS_SELECT_WAIT:
+ break;
+
+ /*
+ * States that are interrupted by the occurrence of a signal
+ * other than the scheduling alarm:
+ */
+ case PS_SLEEP_WAIT:
+ case PS_SIGWAIT:
+ case PS_WAIT_WAIT:
+ /* Flag the operation as interrupted: */
+ pthread->interrupted = 1;
+
+ /* Change the state of the thread to run: */
+ PTHREAD_NEW_STATE(pthread,PS_RUNNING);
+
+ /* Return the signal number: */
+ pthread->signo = sig;
+ break;
+ }
+ } else {
/*
+ * System calls are flagged for restart.
+ *
* Process according to thread state:
*/
switch (pthread->state) {
OpenPOWER on IntegriCloud