* 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
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2007, Axel Dörfler, [email protected].
|
* Copyright 2002-2008, Axel Dörfler, [email protected].
|
||||||
* Copyright 2002, Angelo Mottola, [email protected].
|
* Copyright 2002, Angelo Mottola, [email protected].
|
||||||
*
|
*
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* POSIX signals handling routines */
|
/*! POSIX signals handling routines */
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -617,7 +617,8 @@ has_signals_pending(void *_thread)
|
|||||||
if (thread == NULL)
|
if (thread == NULL)
|
||||||
thread = thread_get_current_thread();
|
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.
|
/*! \brief sigaction() for the specified thread.
|
||||||
*
|
A \a threadID is < 0 specifies the current thread.
|
||||||
* A \a threadID is < 0 specifies the current thread.
|
*/
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
int
|
int
|
||||||
sigaction_etc(thread_id threadID, int signal, const struct sigaction *act,
|
sigaction_etc(thread_id threadID, int signal, const struct sigaction *act,
|
||||||
struct sigaction *oldAction)
|
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
|
static int32
|
||||||
alarm_event(timer *t)
|
alarm_event(timer *t)
|
||||||
{
|
{
|
||||||
@@ -731,7 +728,8 @@ alarm_event(timer *t)
|
|||||||
// set_alarm().
|
// set_alarm().
|
||||||
// Since thread->alarm is this timer structure, we can just
|
// Since thread->alarm is this timer structure, we can just
|
||||||
// cast it back - ugly but it works for now
|
// 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
|
// ToDo: investigate adding one user parameter to the timer structure to fix this hack
|
||||||
|
|
||||||
TRACE(("alarm_event: thread = %p\n", thread));
|
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
|
/*! Sets the alarm timer for the current thread. The timer fires at the
|
||||||
* specified time in the future, periodically or just once, as determined
|
specified time in the future, periodically or just once, as determined
|
||||||
* by \a mode.
|
by \a mode.
|
||||||
* \return the time left until a previous set alarm would have fired.
|
\return the time left until a previous set alarm would have fired.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bigtime_t
|
bigtime_t
|
||||||
set_alarm(bigtime_t time, uint32 mode)
|
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.
|
/*! Replace the current signal block mask and wait for any event to happen.
|
||||||
* Before returning, the original signal block mask is reinstantiated.
|
Before returning, the original signal block mask is reinstantiated.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int
|
int
|
||||||
sigsuspend(const sigset_t *mask)
|
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
|
// Set the new block mask and interuptably block wait for a condition
|
||||||
// variable no one will ever notify.
|
// variable no one will ever notify.
|
||||||
|
|
||||||
atomic_set(&thread->sig_block_mask, *mask);
|
atomic_set(&thread->sig_block_mask, *mask & BLOCKABLE_SIGNALS);
|
||||||
|
|
||||||
ConditionVariable<sigset_t> conditionVar;
|
ConditionVariable<sigset_t> conditionVar;
|
||||||
conditionVar.Publish(mask, "sigsuspend");
|
conditionVar.Publish(mask, "sigsuspend");
|
||||||
|
|||||||
Reference in New Issue
Block a user