12
12
fb055f2 Hurd signals: fix global untraced signals.
15
hurd/ctty-input.c | 18 ++-
16
hurd/ctty-output.c | 18 ++-
17
hurd/hurd/signal.h | 40 ++++--
18
hurd/hurdexec.c | 11 +-
19
hurd/hurdmsg.c | 27 +---
20
hurd/hurdsig.c | 272 +++++++++++++++++++++++++++--------
21
sysdeps/mach/hurd/fork.c | 9 +-
22
sysdeps/mach/hurd/i386/sigreturn.c | 13 +-
23
sysdeps/mach/hurd/i386/trampoline.c | 8 +-
24
sysdeps/mach/hurd/sigaction.c | 18 ++--
25
sysdeps/mach/hurd/sigpending.c | 9 +-
26
sysdeps/mach/hurd/sigprocmask.c | 11 +-
27
sysdeps/mach/hurd/sigsuspend.c | 19 ++--
28
sysdeps/mach/hurd/sigwait.c | 23 ++--
29
sysdeps/mach/hurd/spawni.c | 23 ++--
15
hurd/ctty-input.c | 18 +-
16
hurd/ctty-output.c | 18 +-
17
hurd/hurd/signal.h | 40 +++--
18
hurd/hurdexec.c | 11 -
19
hurd/hurdmsg.c | 27 ---
20
hurd/hurdsig.c | 272 +++++++++++++++++++++++++++---------
21
sysdeps/mach/hurd/fork.c | 9 -
22
sysdeps/mach/hurd/i386/sigreturn.c | 13 -
23
sysdeps/mach/hurd/i386/trampoline.c | 8 -
24
sysdeps/mach/hurd/sigaction.c | 18 +-
25
sysdeps/mach/hurd/sigpending.c | 9 -
26
sysdeps/mach/hurd/sigprocmask.c | 11 -
27
sysdeps/mach/hurd/sigsuspend.c | 19 +-
28
sysdeps/mach/hurd/sigwait.c | 23 +--
29
sysdeps/mach/hurd/spawni.c | 23 +--
30
30
15 files changed, 350 insertions(+), 169 deletions(-)
32
diff --git a/hurd/ctty-input.c b/hurd/ctty-input.c
33
index ef8395a..4da33c7 100644
34
32
--- a/hurd/ctty-input.c
35
33
+++ b/hurd/ctty-input.c
40
38
This file is part of the GNU C Library.
42
40
The GNU C Library is free software; you can redistribute it and/or
43
@@ -44,12 +44,15 @@ _hurd_ctty_input (io_t port, io_t ctty, error_t (*rpc) (io_t))
46
44
struct hurd_sigstate *ss = _hurd_self_sigstate ();
60
58
if (err == EBACKGROUND)
62
@@ -66,10 +69,11 @@ _hurd_ctty_input (io_t port, io_t ctty, error_t (*rpc) (io_t))
63
61
SIGTTIN or resumed after being stopped. Now this is
64
62
still a "system call", so check to see if we should
85
81
This file is part of the GNU C Library.
87
83
The GNU C Library is free software; you can redistribute it and/or
88
@@ -35,16 +35,19 @@ _hurd_ctty_output (io_t port, io_t ctty, error_t (*rpc) (io_t))
110
106
return (*rpc) (port);
111
@@ -71,10 +74,11 @@ _hurd_ctty_output (io_t port, io_t ctty, error_t (*rpc) (io_t))
112
108
SIGTTOU or resumed after being stopped. Now this is
113
109
still a "system call", so check to see if we should
134
128
Free Software Foundation, Inc.
135
129
This file is part of the GNU C Library.
137
@@ -71,7 +71,13 @@ struct hurd_sigstate
139
133
sigset_t blocked; /* What signals are blocked. */
140
134
sigset_t pending; /* Pending signals, possibly blocked. */
148
142
struct sigaltstack sigaltstack;
150
144
/* Chain of thread-local signal preemptors; see <hurd/sigpreempt.h>.
151
@@ -127,6 +133,26 @@ extern struct hurd_sigstate *_hurd_self_sigstate (void)
152
146
by different threads. */
153
147
__attribute__ ((__const__));
175
169
#ifndef _HURD_SIGNAL_H_EXTERN_INLINE
176
170
#define _HURD_SIGNAL_H_EXTERN_INLINE __extern_inline
178
@@ -150,12 +176,6 @@ extern thread_t _hurd_msgport_thread;
180
174
extern mach_port_t _hurd_msgport;
188
182
/* Resource limit on core file size. Enforced by hurdsig.c. */
189
183
extern int _hurd_core_limit;
191
@@ -203,10 +223,10 @@ _hurd_critical_section_unlock (void *our_lock)
185
@@ -211,10 +231,10 @@
192
186
/* It was us who acquired the critical section lock. Unlock it. */
193
struct hurd_sigstate *ss = our_lock;
187
struct hurd_sigstate *ss = (struct hurd_sigstate *) our_lock;
194
188
sigset_t pending;
195
189
- __spin_lock (&ss->lock);
196
190
+ _hurd_sigstate_lock (ss);
202
196
if (! __sigisemptyset (&pending))
203
197
/* There are unblocked signals pending, which weren't
204
198
delivered because we were in the critical section.
205
diff --git a/hurd/hurdexec.c b/hurd/hurdexec.c
206
index beae869..ee3162f 100644
207
199
--- a/hurd/hurdexec.c
208
200
+++ b/hurd/hurdexec.c
212
204
Free Software Foundation, Inc.
213
205
This file is part of the GNU C Library.
215
@@ -109,12 +109,13 @@ _hurd_exec (task_t task, file_t file,
207
@@ -108,12 +108,13 @@
216
208
assert (! __spin_lock_locked (&ss->critical_section_lock));
217
209
__spin_lock (&ss->critical_section_lock);
229
221
ints[INIT_SIGIGN] |= __sigmask (i);
231
223
/* We hold the sigstate lock until the exec has failed so that no signal
232
@@ -125,7 +126,7 @@ _hurd_exec (task_t task, file_t file,
233
225
critical section flag avoids anything we call trying to acquire the
234
226
sigstate lock. */
249
239
This file is part of the GNU C Library.
251
241
The GNU C Library is free software; you can redistribute it and/or
252
@@ -122,17 +123,9 @@ get_int (int which, int *value)
254
244
*value = _hurd_umask;
306
296
const sigset_t ign = value;
307
297
__spin_lock (&ss->lock);
308
diff --git a/hurd/hurdsig.c b/hurd/hurdsig.c
309
index 74a01a6..67037e8 100644
310
298
--- a/hurd/hurdsig.c
311
299
+++ b/hurd/hurdsig.c
312
@@ -44,9 +44,6 @@ mach_port_t _hurd_msgport;
313
301
/* Thread listening on it. */
314
302
thread_t _hurd_msgport_thread;
319
307
/* These are set up by _hurdsig_init. */
320
308
unsigned long int __hurd_sigthread_stack_base;
321
309
unsigned long int __hurd_sigthread_stack_end;
322
@@ -55,6 +52,9 @@ unsigned long int *__hurd_sigthread_variables;
323
311
/* Linked-list of per-thread signal state. */
324
312
struct hurd_sigstate *_hurd_sigstates;
329
317
/* Timeout for RPC's after interrupt_operation. */
330
318
mach_msg_timeout_t _hurd_interrupted_rpc_timeout = 3000;
332
@@ -83,7 +83,7 @@ _hurd_thread_sigstate (thread_t thread)
334
322
ss = malloc (sizeof (*ss));
479
467
/* Signal delivery itself is on this page. */
481
@@ -216,6 +313,8 @@ static void
482
470
abort_thread (struct hurd_sigstate *ss, struct machine_thread_all_state *state,
483
471
void (*reply) (void))
487
475
if (!(state->set & THREAD_ABORTED))
489
477
error_t err = __thread_abort (ss->thread);
490
@@ -355,7 +454,7 @@ _hurdsig_abort_rpcs (struct hurd_sigstate *ss, int signo, int sigthread,
491
479
call above will retry their RPCs unless we clear SS->intr_port.
492
480
So we clear it for the thread taking a signal when SA_RESTART is
493
481
clear, so that its call returns EINTR. */
496
484
ss->intr_port = MACH_PORT_NULL;
499
@@ -478,9 +577,11 @@ weak_alias (_hurdsig_preemptors, _hurdsig_preempters)
500
488
sigmask (SIGSTOP) | sigmask (SIGTSTP))
502
490
/* Actual delivery of a single signal. Called with SS unlocked. When
511
499
post_signal (struct hurd_sigstate *ss,
512
500
int signo, struct hurd_signal_detail *detail,
513
501
int untraced, void (*reply) (void))
514
@@ -533,8 +634,12 @@ post_signal (struct hurd_sigstate *ss,
515
503
assert_perror (err);
516
504
for (i = 0; i < nthreads; ++i)
527
515
err = __thread_resume (threads[i]);
528
516
assert_perror (err);
529
@@ -547,9 +652,6 @@ post_signal (struct hurd_sigstate *ss,
530
518
(vm_address_t) threads,
531
519
nthreads * sizeof *threads);
532
520
_hurd_stopped = 0;
600
588
if (handler == SIG_DFL)
601
589
/* Figure out the default action for this signal. */
602
@@ -728,7 +860,7 @@ post_signal (struct hurd_sigstate *ss,
604
592
/* Handle receipt of a blocked signal, or any signal while stopped. */
605
593
if (act != ignore && /* Signals ignored now are forgotten now. */
608
596
(signo != SIGKILL && _hurd_stopped))
611
@@ -764,6 +896,7 @@ post_signal (struct hurd_sigstate *ss,
612
600
now's the time to set it going. */
613
601
if (ss_suspended)
616
604
err = __thread_resume (ss->thread);
617
605
assert_perror (err);
618
606
ss_suspended = 0;
619
@@ -808,6 +941,8 @@ post_signal (struct hurd_sigstate *ss,
620
608
struct sigcontext *scp, ocontext;
621
609
int wait_for_reply, state_changed;
666
654
/* Return the set of pending signals in SS which should be delivered. */
667
@@ -991,7 +1128,7 @@ pending_signals (struct hurd_sigstate *ss)
668
656
if (_hurd_stopped || __spin_lock_locked (&ss->critical_section_lock))
675
663
/* Post the specified pending signals in SS and return 1. If one of
676
@@ -1003,12 +1140,15 @@ post_pending (struct hurd_sigstate *ss, sigset_t pending, void (*reply) (void))
664
@@ -1002,12 +1139,15 @@
678
666
struct hurd_signal_detail detail;
693
681
/* Will reacquire the lock, except if the signal is traced. */
694
682
if (! post_signal (ss, signo, &detail, 0, reply))
695
@@ -1016,7 +1156,7 @@ post_pending (struct hurd_sigstate *ss, sigset_t pending, void (*reply) (void))
683
@@ -1015,7 +1155,7 @@
698
686
/* No more signals pending; SS->lock is still locked. */
734
722
/* The signal has either been ignored or is now being handled. We can
735
723
consider it delivered and reply to the killer. */
736
@@ -1090,8 +1231,9 @@ _hurd_internal_post_signal (struct hurd_sigstate *ss,
724
@@ -1089,8 +1230,9 @@
759
747
signo, &d, reply_port, reply_port_type,
760
748
0); /* Stop if traced. */
762
@@ -1247,7 +1390,7 @@ _S_msg_sig_post_untraced (mach_port_t me,
750
@@ -1246,7 +1389,7 @@
764
752
/* Post the signal to the designated signal-receiving thread. This will
765
753
reply when the signal can be considered delivered. */
768
756
signo, &d, reply_port, reply_port_type,
769
757
1); /* Untraced flag. */
771
@@ -1258,8 +1401,8 @@ extern void __mig_init (void *);
759
@@ -1257,8 +1400,8 @@
773
761
#include <mach/task_special_ports.h>
781
769
_hurdsig_init (const int *intarray, size_t intarraysize)
782
@@ -1282,27 +1425,34 @@ _hurdsig_init (const int *intarray, size_t intarraysize)
770
@@ -1281,27 +1424,34 @@
783
771
MACH_MSG_TYPE_MAKE_SEND);
784
772
assert_perror (err);
822
810
/* Start the signal thread listening on the message port. */
824
812
if (__hurd_threadvar_stack_mask == 0)
825
diff --git a/sysdeps/mach/hurd/fork.c b/sysdeps/mach/hurd/fork.c
826
index 66fa7e2..bae4204 100644
827
813
--- a/sysdeps/mach/hurd/fork.c
828
814
+++ b/sysdeps/mach/hurd/fork.c
829
@@ -459,6 +459,7 @@ __fork (void)
830
816
function, accounted for by mach_port_names (and which will thus be
831
817
accounted for in the child below). This extra right gets consumed
832
818
in the child by the store into _hurd_sigthread in the child fork. */
834
820
if (thread_refs > 1 &&
835
821
(err = __mach_port_mod_refs (newtask, ss->thread,
836
822
MACH_PORT_RIGHT_SEND,
837
@@ -616,10 +617,6 @@ __fork (void)
838
824
for (i = 0; i < _hurd_nports; ++i)
839
825
__spin_unlock (&_hurd_ports[i].lock);
845
831
/* Claim our sigstate structure and unchain the rest: the
846
832
threads existed in the parent task but don't exist in this
847
833
task (the child process). Delay freeing them until later
848
@@ -640,6 +637,10 @@ __fork (void)
849
835
_hurd_sigstates = ss;
850
836
__mutex_unlock (&_hurd_siglock);
856
842
/* Fetch our new process IDs from the proc server. No need to
857
843
refetch our pgrp; it is always inherited from the parent (so
858
844
_hurd_pgrp is already correct), and the proc server will send us a
859
diff --git a/sysdeps/mach/hurd/i386/sigreturn.c b/sysdeps/mach/hurd/i386/sigreturn.c
860
index 60b0d00..8cb92ef 100644
861
845
--- a/sysdeps/mach/hurd/i386/sigreturn.c
862
846
+++ b/sysdeps/mach/hurd/i386/sigreturn.c
867
851
This file is part of the GNU C Library.
869
853
The GNU C Library is free software; you can redistribute it and/or
870
@@ -39,7 +40,7 @@ __sigreturn (struct sigcontext *scp)
873
857
ss = _hurd_self_sigstate ();
877
861
/* Remove the link on the `active resources' chain added by
878
862
_hurd_setup_sighandler. Its purpose was to make sure
879
@@ -51,19 +52,19 @@ __sigreturn (struct sigcontext *scp)
880
864
ss->intr_port = scp->sc_intr_port;
882
866
/* Check for pending signals that were blocked by the old set. */
909
893
/* Destroy the MiG reply port used by the signal handler, and restore the
910
894
reply port in use by the thread when interrupted. */
911
diff --git a/sysdeps/mach/hurd/i386/trampoline.c b/sysdeps/mach/hurd/i386/trampoline.c
912
index 99d9308..ec52847 100644
913
895
--- a/sysdeps/mach/hurd/i386/trampoline.c
914
896
+++ b/sysdeps/mach/hurd/i386/trampoline.c
919
901
Free Software Foundation, Inc.
920
902
This file is part of the GNU C Library.
922
@@ -77,7 +77,11 @@ _hurd_setup_sighandler (struct hurd_sigstate *ss, __sighandler_t handler,
923
905
interrupted RPC frame. */
924
906
state->basic.esp = state->basic.uesp;
932
914
!(ss->sigaltstack.ss_flags & (SS_DISABLE|SS_ONSTACK)))
934
916
sigsp = ss->sigaltstack.ss_sp + ss->sigaltstack.ss_size;
935
diff --git a/sysdeps/mach/hurd/sigaction.c b/sysdeps/mach/hurd/sigaction.c
936
index fe452e8..bedf14c 100644
937
917
--- a/sysdeps/mach/hurd/sigaction.c
938
918
+++ b/sysdeps/mach/hurd/sigaction.c
942
922
Free Software Foundation, Inc.
944
924
This file is part of the GNU C Library.
945
@@ -51,15 +51,15 @@ __sigaction (sig, act, oact)
946
926
ss = _hurd_self_sigstate ();
948
928
__spin_lock (&ss->critical_section_lock);
963
943
/* Inform the proc server whether or not it should send us SIGCHLD for
964
944
stopped children. We do this in a critical section so that no
965
@@ -67,8 +67,8 @@ __sigaction (sig, act, oact)
967
947
__proc_mod_stopchild (port, !(a.sa_flags & SA_NOCLDSTOP)));
974
954
else if (act != NULL && (a.sa_handler == SIG_IGN || a.sa_handler == SIG_DFL))
975
955
/* We are changing to an action that might be to ignore SIG signals.
976
@@ -77,11 +77,11 @@ __sigaction (sig, act, oact)
977
957
back and then SIG is unblocked, the signal pending now should not
978
958
arrive. So wake up the signal thread to check the new state and do
979
959
the right thing. */
987
967
__spin_unlock (&ss->critical_section_lock);
990
diff --git a/sysdeps/mach/hurd/sigpending.c b/sysdeps/mach/hurd/sigpending.c
991
index 84ac927..f582d45 100644
992
970
--- a/sysdeps/mach/hurd/sigpending.c
993
971
+++ b/sysdeps/mach/hurd/sigpending.c
998
976
This file is part of the GNU C Library.
1000
978
The GNU C Library is free software; you can redistribute it and/or
1001
@@ -38,9 +39,9 @@ sigpending (set)
1004
982
ss = _hurd_self_sigstate ();
1022
998
This file is part of the GNU C Library.
1024
1000
The GNU C Library is free software; you can redistribute it and/or
1025
@@ -40,7 +41,7 @@ __sigprocmask (how, set, oset)
1027
1003
ss = _hurd_self_sigstate ();
1089
1063
/* Tell the signal thread to check for pending signals. */
1090
@@ -66,10 +66,11 @@ __sigsuspend (set)
1091
1065
MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
1092
1066
__mach_port_destroy (__mach_task_self (), wait);
1105
1079
/* Tell the signal thread to check for pending signals. */
1106
diff --git a/sysdeps/mach/hurd/sigwait.c b/sysdeps/mach/hurd/sigwait.c
1107
index 9794076..af50f74 100644
1108
1080
--- a/sysdeps/mach/hurd/sigwait.c
1109
1081
+++ b/sysdeps/mach/hurd/sigwait.c
1110
1082
@@ -1,4 +1,4 @@
1113
1085
This file is part of the GNU C Library.
1115
1087
The GNU C Library is free software; you can redistribute it and/or
1116
@@ -28,7 +28,7 @@ int
1117
1089
__sigwait (const sigset_t *set, int *sig)
1119
1091
struct hurd_sigstate *ss;
1123
1095
struct hurd_signal_preemptor preemptor;
1125
@@ -50,8 +50,8 @@ __sigwait (const sigset_t *set, int *sig)
1126
1098
/* Make sure this is all kosher */
1127
1099
assert (__sigismember (&mask, signo));
1147
1119
if (! __sigisemptyset (&ready))
1149
1121
for (signo = 1; signo < NSIG; signo++)
1150
@@ -103,7 +104,11 @@ __sigwait (const sigset_t *set, int *sig)
1122
@@ -102,7 +103,11 @@
1151
1123
preemptor.next = ss->preemptors;
1152
1124
ss->preemptors = &preemptor;
1162
1134
__mach_msg (&msg, MACH_RCV_MSG, 0, sizeof (msg), wait,
1163
@@ -114,7 +119,7 @@ __sigwait (const sigset_t *set, int *sig)
1165
1137
assert (signo);
1170
1142
/* Delete our preemptor. */
1171
1143
assert (ss->preemptors == &preemptor);
1172
@@ -123,7 +128,7 @@ __sigwait (const sigset_t *set, int *sig)
1179
1151
__mach_port_destroy (__mach_task_self (), wait);
1181
diff --git a/sysdeps/mach/hurd/spawni.c b/sysdeps/mach/hurd/spawni.c
1182
index 3d2b591..c12f448 100644
1183
1153
--- a/sysdeps/mach/hurd/spawni.c
1184
1154
+++ b/sysdeps/mach/hurd/spawni.c
1185
@@ -239,26 +239,29 @@ __spawni (pid_t *pid, const char *file,
1155
@@ -238,26 +238,29 @@
1186
1156
assert (! __spin_lock_locked (&ss->critical_section_lock));
1187
1157
__spin_lock (&ss->critical_section_lock);