mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-08 17:42:12 +03:00
hurd: set sigaction for signal preemptors in arch-independent file
Instead of having the arch-specific trampoline setup code detect whether preemption happened or not, we'd rather pass it the sigaction. In the future, this may also allow to change sa_flags from post_signal().
This commit is contained in:
@@ -327,7 +327,8 @@ extern void _hurd_internal_post_signal (struct hurd_sigstate *ss,
|
|||||||
|
|
||||||
struct machine_thread_all_state;
|
struct machine_thread_all_state;
|
||||||
extern struct sigcontext *
|
extern struct sigcontext *
|
||||||
_hurd_setup_sighandler (struct hurd_sigstate *ss, __sighandler_t handler,
|
_hurd_setup_sighandler (struct hurd_sigstate *ss, const struct sigaction *action,
|
||||||
|
__sighandler_t handler,
|
||||||
int signo, struct hurd_signal_detail *detail,
|
int signo, struct hurd_signal_detail *detail,
|
||||||
int rpc_wait, struct machine_thread_all_state *state);
|
int rpc_wait, struct machine_thread_all_state *state);
|
||||||
|
|
||||||
|
@@ -624,6 +624,13 @@ post_signal (struct hurd_sigstate *ss,
|
|||||||
enum { stop, ignore, core, term, handle } act;
|
enum { stop, ignore, core, term, handle } act;
|
||||||
int ss_suspended;
|
int ss_suspended;
|
||||||
|
|
||||||
|
/* sigaction for preemptors */
|
||||||
|
struct sigaction preempt_sigaction = {
|
||||||
|
.sa_flags = SA_RESTART
|
||||||
|
};
|
||||||
|
|
||||||
|
struct sigaction *action;
|
||||||
|
|
||||||
/* Mark the signal as pending. */
|
/* Mark the signal as pending. */
|
||||||
void mark_pending (void)
|
void mark_pending (void)
|
||||||
{
|
{
|
||||||
@@ -780,12 +787,17 @@ post_signal (struct hurd_sigstate *ss,
|
|||||||
/* Ignore the signal altogether. */
|
/* Ignore the signal altogether. */
|
||||||
act = ignore;
|
act = ignore;
|
||||||
else if (handler != SIG_ERR)
|
else if (handler != SIG_ERR)
|
||||||
|
{
|
||||||
/* Run the preemption-provided handler. */
|
/* Run the preemption-provided handler. */
|
||||||
|
action = &preempt_sigaction;
|
||||||
act = handle;
|
act = handle;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* No preemption. Do normal handling. */
|
/* No preemption. Do normal handling. */
|
||||||
|
|
||||||
|
action = & _hurd_sigstate_actions (ss) [signo];
|
||||||
|
|
||||||
if (!untraced && __sigismember (&_hurdsig_traced, signo))
|
if (!untraced && __sigismember (&_hurdsig_traced, signo))
|
||||||
{
|
{
|
||||||
/* We are being traced. Stop to tell the debugger of the signal. */
|
/* We are being traced. Stop to tell the debugger of the signal. */
|
||||||
@@ -800,7 +812,7 @@ post_signal (struct hurd_sigstate *ss,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
handler = _hurd_sigstate_actions (ss) [signo].sa_handler;
|
handler = action->sa_handler;
|
||||||
|
|
||||||
if (handler == SIG_DFL)
|
if (handler == SIG_DFL)
|
||||||
/* Figure out the default action for this signal. */
|
/* Figure out the default action for this signal. */
|
||||||
@@ -1072,7 +1084,7 @@ post_signal (struct hurd_sigstate *ss,
|
|||||||
|
|
||||||
/* Call the machine-dependent function to set the thread up
|
/* Call the machine-dependent function to set the thread up
|
||||||
to run the signal handler, and preserve its old context. */
|
to run the signal handler, and preserve its old context. */
|
||||||
scp = _hurd_setup_sighandler (ss, handler, signo, detail,
|
scp = _hurd_setup_sighandler (ss, action, handler, signo, detail,
|
||||||
wait_for_reply, &thread_state);
|
wait_for_reply, &thread_state);
|
||||||
if (scp == NULL)
|
if (scp == NULL)
|
||||||
goto sigbomb;
|
goto sigbomb;
|
||||||
@@ -1111,8 +1123,6 @@ post_signal (struct hurd_sigstate *ss,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct sigaction *action = & _hurd_sigstate_actions (ss) [signo];
|
|
||||||
|
|
||||||
/* Backdoor extra argument to signal handler. */
|
/* Backdoor extra argument to signal handler. */
|
||||||
scp->sc_error = detail->error;
|
scp->sc_error = detail->error;
|
||||||
|
|
||||||
|
@@ -80,7 +80,8 @@ static void fill_ucontext (ucontext_t *uc, const struct sigcontext *sc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct sigcontext *
|
struct sigcontext *
|
||||||
_hurd_setup_sighandler (struct hurd_sigstate *ss, __sighandler_t handler,
|
_hurd_setup_sighandler (struct hurd_sigstate *ss, const struct sigaction *action,
|
||||||
|
__sighandler_t handler,
|
||||||
int signo, struct hurd_signal_detail *detail,
|
int signo, struct hurd_signal_detail *detail,
|
||||||
volatile int rpc_wait,
|
volatile int rpc_wait,
|
||||||
struct machine_thread_all_state *state)
|
struct machine_thread_all_state *state)
|
||||||
@@ -90,7 +91,6 @@ _hurd_setup_sighandler (struct hurd_sigstate *ss, __sighandler_t handler,
|
|||||||
void firewall (void);
|
void firewall (void);
|
||||||
extern const void _hurd_intr_rpc_msg_cx_sp;
|
extern const void _hurd_intr_rpc_msg_cx_sp;
|
||||||
extern const void _hurd_intr_rpc_msg_sp_restored;
|
extern const void _hurd_intr_rpc_msg_sp_restored;
|
||||||
const struct sigaction *action;
|
|
||||||
void *volatile sigsp;
|
void *volatile sigsp;
|
||||||
struct sigcontext *scp;
|
struct sigcontext *scp;
|
||||||
struct
|
struct
|
||||||
@@ -123,11 +123,6 @@ _hurd_setup_sighandler (struct hurd_sigstate *ss, __sighandler_t handler,
|
|||||||
siginfo_t siginfo;
|
siginfo_t siginfo;
|
||||||
} *stackframe;
|
} *stackframe;
|
||||||
|
|
||||||
/* sigaction for preemptors */
|
|
||||||
static const struct sigaction legacy_sigaction = {
|
|
||||||
.sa_flags = SA_RESTART
|
|
||||||
};
|
|
||||||
|
|
||||||
if (ss->context)
|
if (ss->context)
|
||||||
{
|
{
|
||||||
/* We have a previous sigcontext that sigreturn was about
|
/* We have a previous sigcontext that sigreturn was about
|
||||||
@@ -170,14 +165,6 @@ _hurd_setup_sighandler (struct hurd_sigstate *ss, __sighandler_t handler,
|
|||||||
the SP on sigreturn. */
|
the SP on sigreturn. */
|
||||||
state->basic.uesp = state->basic.ecx;
|
state->basic.uesp = state->basic.ecx;
|
||||||
|
|
||||||
action = & _hurd_sigstate_actions (ss) [signo];
|
|
||||||
if ( (action->sa_flags & SA_SIGINFO)
|
|
||||||
&& handler != (__sighandler_t) action->sa_sigaction
|
|
||||||
|| !(action->sa_flags & SA_SIGINFO)
|
|
||||||
&& handler != action->sa_handler)
|
|
||||||
/* A signal preemptor took over, use legacy semantic. */
|
|
||||||
action = &legacy_sigaction;
|
|
||||||
|
|
||||||
if ((action->sa_flags & SA_ONSTACK)
|
if ((action->sa_flags & SA_ONSTACK)
|
||||||
&& !(ss->sigaltstack.ss_flags & (SS_DISABLE|SS_ONSTACK)))
|
&& !(ss->sigaltstack.ss_flags & (SS_DISABLE|SS_ONSTACK)))
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user