From 447c081fe41c755a130cfa8fd8c351c5e936685e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 18 Feb 2008 12:31:17 +0000 Subject: [PATCH] * sigsuspend() must only block blockable signals. * Minor comment cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24000 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/signal.cpp | 42 ++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/src/system/kernel/signal.cpp b/src/system/kernel/signal.cpp index f9156a2e1e..2fd2eeaa9c 100644 --- a/src/system/kernel/signal.cpp +++ b/src/system/kernel/signal.cpp @@ -1,11 +1,11 @@ /* - * Copyright 2002-2007, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2002-2008, Axel Dörfler, axeld@pinc-software.de. * Copyright 2002, Angelo Mottola, a.mottola@libero.it. * * Distributed under the terms of the MIT License. */ -/* POSIX signals handling routines */ +/*! POSIX signals handling routines */ #include #include @@ -617,7 +617,8 @@ has_signals_pending(void *_thread) if (thread == NULL) thread = thread_get_current_thread(); - return atomic_get(&thread->sig_pending) & ~atomic_get(&thread->sig_block_mask); + return atomic_get(&thread->sig_pending) + & ~atomic_get(&thread->sig_block_mask); } @@ -654,12 +655,9 @@ sigprocmask(int how, const sigset_t *set, sigset_t *oldSet) } -/** \brief sigaction() for the specified thread. - * - * A \a threadID is < 0 specifies the current thread. - * - */ - +/*! \brief sigaction() for the specified thread. + A \a threadID is < 0 specifies the current thread. +*/ int sigaction_etc(thread_id threadID, int signal, const struct sigaction *act, struct sigaction *oldAction) @@ -721,8 +719,7 @@ sigaction(int signal, const struct sigaction *act, struct sigaction *oldAction) } -/** Triggers a SIGALRM to the thread that issued the timer and reschedules */ - +/*! Triggers a SIGALRM to the thread that issued the timer and reschedules */ static int32 alarm_event(timer *t) { @@ -731,7 +728,8 @@ alarm_event(timer *t) // set_alarm(). // Since thread->alarm is this timer structure, we can just // cast it back - ugly but it works for now - struct thread *thread = (struct thread *)((uint8 *)t - offsetof(struct thread, alarm)); + struct thread *thread = (struct thread *)((uint8 *)t + - offsetof(struct thread, alarm)); // ToDo: investigate adding one user parameter to the timer structure to fix this hack TRACE(("alarm_event: thread = %p\n", thread)); @@ -741,12 +739,11 @@ alarm_event(timer *t) } -/** Sets the alarm timer for the current thread. The timer fires at the - * specified time in the future, periodically or just once, as determined - * by \a mode. - * \return the time left until a previous set alarm would have fired. - */ - +/*! Sets the alarm timer for the current thread. The timer fires at the + specified time in the future, periodically or just once, as determined + by \a mode. + \return the time left until a previous set alarm would have fired. +*/ bigtime_t set_alarm(bigtime_t time, uint32 mode) { @@ -774,10 +771,9 @@ set_alarm(bigtime_t time, uint32 mode) } -/** Replace the current signal block mask and wait for any event to happen. - * Before returning, the original signal block mask is reinstantiated. - */ - +/*! Replace the current signal block mask and wait for any event to happen. + Before returning, the original signal block mask is reinstantiated. +*/ int sigsuspend(const sigset_t *mask) { @@ -787,7 +783,7 @@ sigsuspend(const sigset_t *mask) // Set the new block mask and interuptably block wait for a condition // variable no one will ever notify. - atomic_set(&thread->sig_block_mask, *mask); + atomic_set(&thread->sig_block_mask, *mask & BLOCKABLE_SIGNALS); ConditionVariable conditionVar; conditionVar.Publish(mask, "sigsuspend");