aboutsummaryrefslogtreecommitdiff
path: root/hurd/hurdsig.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1996-01-04 10:00:22 +0000
committerRoland McGrath <roland@gnu.org>1996-01-04 10:00:22 +0000
commitfb8e70d6dd3a9c3a0e0d2713b5be3cbc9d7a6409 (patch)
treed465aa6b6c500395145dc09bc4ea448392cf1a6a /hurd/hurdsig.c
parent67f27f3a02d623331a56cddee2a56c34b3b13bd9 (diff)
downloadglibc-fb8e70d6dd3a9c3a0e0d2713b5be3cbc9d7a6409.tar
glibc-fb8e70d6dd3a9c3a0e0d2713b5be3cbc9d7a6409.tar.gz
glibc-fb8e70d6dd3a9c3a0e0d2713b5be3cbc9d7a6409.tar.bz2
glibc-fb8e70d6dd3a9c3a0e0d2713b5be3cbc9d7a6409.zip
Wed Jan 3 20:23:42 1996 Roland McGrath <roland@churchy.gnu.ai.mit.edu>cvs/libc-960104
* hurd/catch-signal.c: New file. * hurd/intr-msg.c: When restarting RPC, fetch a new reply port. * hurd/hurdsig.c: Use new hurdfault.h interface. (abort_all_rpcs): Mutate return value to EINTR in threads whose replies we will wait for. * hurd/hurdkill.c (_hurd_sig_post): When doing pgrp, make sure we do ourselves last. Wed Jan 3 19:17:10 1996 Miles Bader <miles@gnu.ai.mit.edu> * sysdeps/mach/hurd/access.c (__access): Put the uid/gid arguments to auth_makeauth() in the right order. Wed Jan 3 17:19:04 1996 Roland McGrath <roland@churchy.gnu.ai.mit.edu> * sysdeps/generic/strsep.c: Rewritten. * sysdeps/mach/hurd/fork.c: Use a different workaround for the suspended page fault deadlock kernel bug: thread_abort our signal thread first thing after proc_dostop. * sysdeps/mach/hurd/setgid.c: Rewrote gid frobnication to recognize rootness properly. * hurd/hurdsig.c: Use new signal preemption interface.
Diffstat (limited to 'hurd/hurdsig.c')
-rw-r--r--hurd/hurdsig.c77
1 files changed, 52 insertions, 25 deletions
diff --git a/hurd/hurdsig.c b/hurd/hurdsig.c
index 290dba825e..6085ab14cf 100644
--- a/hurd/hurdsig.c
+++ b/hurd/hurdsig.c
@@ -121,8 +121,9 @@ _hurd_thread_sigstate (thread_t thread)
#include "thread_state.h"
#include <hurd/msg_server.h>
#include <hurd/msg_reply.h> /* For __msg_sig_post_reply. */
-#include <assert.h>
#include <hurd/interrupt.h>
+#include <assert.h>
+#include <unistd.h>
int _hurd_core_limit; /* XXX */
@@ -216,12 +217,9 @@ interrupted_reply_port_location (struct machine_thread_all_state *thread_state,
mach_port_t *portloc = (mach_port_t *) __hurd_threadvar_location_from_sp
(_HURD_THREADVAR_MIG_REPLY, (void *) thread_state->basic.SP);
- if (sigthread && _hurdsig_catch_fault (SIGSEGV))
- {
- assert (_hurdsig_fault_sigcode == (long int) portloc);
- /* Faulted trying to read the stack. */
- return NULL;
- }
+ if (sigthread && _hurdsig_catch_memory_fault (portloc))
+ /* Faulted trying to read the stack. */
+ return NULL;
/* Fault now if this pointer is bogus. */
*(volatile mach_port_t *) portloc = *portloc;
@@ -363,9 +361,9 @@ abort_all_rpcs (int signo, struct machine_thread_all_state *state, int live)
reply_ports = alloca (nthreads * sizeof *reply_ports);
nthreads = 0;
- for (ss = _hurd_sigstates; ss != NULL; ss = ss->next)
+ for (ss = _hurd_sigstates; ss != NULL; ss = ss->next, ++nthreads)
if (ss->thread == _hurd_msgport_thread)
- reply_ports[nthreads++] = MACH_PORT_NULL;
+ reply_ports[nthreads] = MACH_PORT_NULL;
else
{
int state_changed;
@@ -374,15 +372,26 @@ abort_all_rpcs (int signo, struct machine_thread_all_state *state, int live)
/* Abort any operation in progress with interrupt_operation.
Record the reply port the thread is waiting on.
We will wait for all the replies below. */
- reply_ports[nthreads++] = _hurdsig_abort_rpcs (ss, signo, 1,
- state, &state_changed,
- NULL);
- if (state_changed && live)
- /* Aborting the RPC needed to change this thread's state,
- and it might ever run again. So write back its state. */
- __thread_set_state (ss->thread, MACHINE_THREAD_STATE_FLAVOR,
- (natural_t *) &state->basic,
- MACHINE_THREAD_STATE_COUNT);
+ reply_ports[nthreads] = _hurdsig_abort_rpcs (ss, signo, 1,
+ state, &state_changed,
+ NULL);
+ if (live)
+ {
+ if (reply_ports[nthreads] != MACH_PORT_NULL)
+ {
+ /* We will wait for the reply to this RPC below, so the
+ thread must issue a new RPC rather than waiting for the
+ reply to the one it sent. */
+ state->basic.SYSRETURN = EINTR;
+ state_changed = 1;
+ }
+ if (state_changed)
+ /* Aborting the RPC needed to change this thread's state,
+ and it might ever run again. So write back its state. */
+ __thread_set_state (ss->thread, MACHINE_THREAD_STATE_FLAVOR,
+ (natural_t *) &state->basic,
+ MACHINE_THREAD_STATE_COUNT);
+ }
}
/* Wait for replies from all the successfully interrupted RPCs. */
@@ -744,10 +753,8 @@ _hurd_internal_post_signal (struct hurd_sigstate *ss,
mach_port_t *loc;
- if (_hurdsig_catch_fault (SIGSEGV))
+ if (_hurdsig_catch_memory_fault (ss->context))
{
- assert (_hurdsig_fault_sigcode >= (long int) ss->context &&
- _hurdsig_fault_sigcode < (long int) (ss->context + 1));
/* We faulted reading the thread's stack. Forget that
context and pretend it wasn't there. It almost
certainly crash if this handler returns, but that's it's
@@ -1176,14 +1183,34 @@ text_set_element (_hurd_reauth_hook, reauth_proc);
const char *
_hurdsig_getenv (const char *variable)
{
- if (_hurdsig_catch_fault (SIGSEGV))
+ if (_hurdsig_catch_memory_fault (__environ))
/* We bombed in getenv. */
return NULL;
else
{
- const char *value = getenv (variable);
- /* Fault now if VALUE is a bogus string. */
- (void) strlen (value);
+ const size_t len = strlen (variable);
+ char *value = NULL;
+ char *volatile *ep = __environ;
+ while (*ep)
+ {
+ const char *p = *ep;
+ _hurdsig_fault_preempter.first = (long int) p;
+ _hurdsig_fault_preempter.last = VM_MAX_ADDRESS;
+ if (! strncmp (p, variable, len) && p[len] == '=')
+ {
+ char *value;
+ size_t valuelen;
+ p += len + 1;
+ valuelen = strlen (p);
+ _hurdsig_fault_preempter.last = (long int) (p + valuelen);
+ value = malloc (++valuelen);
+ if (value)
+ memcpy (value, p, valuelen);
+ break;
+ }
+ _hurdsig_fault_preempter.first = (long int) ++ep;
+ _hurdsig_fault_preempter.last = (long int) (ep + 1);
+ }
_hurdsig_end_catch_fault ();
return value;
}