1 /* This file handles signals, which are asynchronous events and are generally
2 * a messy and unpleasant business. Signals can be generated by the KILL
3 * system call, or from the keyboard (SIGINT) or from the clock (SIGALRM).
4 * In all cases control eventually passes to check_sig() to see which processes
5 * can be signaled. The actual signaling is done by sig_proc().
7 * The entry points into this file are:
8 * do_sigaction: perform the SIGACTION system call
9 * do_sigpending: perform the SIGPENDING system call
10 * do_sigprocmask: perform the SIGPROCMASK system call
11 * do_sigreturn: perform the SIGRETURN system call
12 * do_sigsuspend: perform the SIGSUSPEND system call
13 * do_kill: perform the KILL system call
14 * do_pause: perform the PAUSE system call
15 * ksig_pending: the kernel notified about pending signals
16 * sig_proc: interrupt or terminate a signaled process
17 * check_sig: check which processes to signal with sig_proc()
18 * check_pending: check if a pending signal can now be delivered
19 * restart_sigs: restart signal work after finishing a FS call
24 #include <sys/ptrace.h>
25 #include <minix/callnr.h>
26 #include <minix/endpoint.h>
27 #include <minix/com.h>
30 #include <sys/resource.h>
31 #include <sys/sigcontext.h>
36 FORWARD
_PROTOTYPE( void unpause
, (struct mproc
*rmp
) );
37 FORWARD
_PROTOTYPE( void handle_ksig
, (int proc_nr
, sigset_t sig_map
) );
38 FORWARD
_PROTOTYPE( int sig_send
, (struct mproc
*rmp
, int signo
) );
40 /*===========================================================================*
42 *===========================================================================*/
43 PUBLIC
int do_sigaction()
46 struct sigaction svec
;
47 struct sigaction
*svp
;
49 if (m_in
.sig_nr
== SIGKILL
) return(OK
);
50 if (m_in
.sig_nr
< 1 || m_in
.sig_nr
>= _NSIG
) return(EINVAL
);
51 svp
= &mp
->mp_sigact
[m_in
.sig_nr
];
52 if ((struct sigaction
*) m_in
.sig_osa
!= (struct sigaction
*) NULL
) {
53 r
= sys_datacopy(PM_PROC_NR
,(vir_bytes
) svp
,
54 who_e
, (vir_bytes
) m_in
.sig_osa
, (phys_bytes
) sizeof(svec
));
55 if (r
!= OK
) return(r
);
58 if ((struct sigaction
*) m_in
.sig_nsa
== (struct sigaction
*) NULL
)
61 /* Read in the sigaction structure. */
62 r
= sys_datacopy(who_e
, (vir_bytes
) m_in
.sig_nsa
,
63 PM_PROC_NR
, (vir_bytes
) &svec
, (phys_bytes
) sizeof(svec
));
64 if (r
!= OK
) return(r
);
66 if (svec
.sa_handler
== SIG_IGN
) {
67 sigaddset(&mp
->mp_ignore
, m_in
.sig_nr
);
68 sigdelset(&mp
->mp_sigpending
, m_in
.sig_nr
);
69 sigdelset(&mp
->mp_catch
, m_in
.sig_nr
);
70 sigdelset(&mp
->mp_sig2mess
, m_in
.sig_nr
);
71 } else if (svec
.sa_handler
== SIG_DFL
) {
72 sigdelset(&mp
->mp_ignore
, m_in
.sig_nr
);
73 sigdelset(&mp
->mp_catch
, m_in
.sig_nr
);
74 sigdelset(&mp
->mp_sig2mess
, m_in
.sig_nr
);
75 } else if (svec
.sa_handler
== SIG_MESS
) {
76 if (! (mp
->mp_flags
& PRIV_PROC
)) return(EPERM
);
77 sigdelset(&mp
->mp_ignore
, m_in
.sig_nr
);
78 sigaddset(&mp
->mp_sig2mess
, m_in
.sig_nr
);
79 sigdelset(&mp
->mp_catch
, m_in
.sig_nr
);
81 sigdelset(&mp
->mp_ignore
, m_in
.sig_nr
);
82 sigaddset(&mp
->mp_catch
, m_in
.sig_nr
);
83 sigdelset(&mp
->mp_sig2mess
, m_in
.sig_nr
);
85 mp
->mp_sigact
[m_in
.sig_nr
].sa_handler
= svec
.sa_handler
;
86 sigdelset(&svec
.sa_mask
, SIGKILL
);
87 sigdelset(&svec
.sa_mask
, SIGSTOP
);
88 mp
->mp_sigact
[m_in
.sig_nr
].sa_mask
= svec
.sa_mask
;
89 mp
->mp_sigact
[m_in
.sig_nr
].sa_flags
= svec
.sa_flags
;
90 mp
->mp_sigreturn
= (vir_bytes
) m_in
.sig_ret
;
94 /*===========================================================================*
96 *===========================================================================*/
97 PUBLIC
int do_sigpending()
99 mp
->mp_reply
.reply_mask
= (long) mp
->mp_sigpending
;
103 /*===========================================================================*
105 *===========================================================================*/
106 PUBLIC
int do_sigprocmask()
108 /* Note that the library interface passes the actual mask in sigmask_set,
109 * not a pointer to the mask, in order to save a copy. Similarly,
110 * the old mask is placed in the return message which the library
111 * interface copies (if requested) to the user specified address.
113 * The library interface must set SIG_INQUIRE if the 'act' argument
116 * KILL and STOP can't be masked.
121 mp
->mp_reply
.reply_mask
= (long) mp
->mp_sigmask
;
123 switch (m_in
.sig_how
) {
125 sigdelset((sigset_t
*)&m_in
.sig_set
, SIGKILL
);
126 sigdelset((sigset_t
*)&m_in
.sig_set
, SIGSTOP
);
127 for (i
= 1; i
< _NSIG
; i
++) {
128 if (sigismember((sigset_t
*)&m_in
.sig_set
, i
))
129 sigaddset(&mp
->mp_sigmask
, i
);
134 for (i
= 1; i
< _NSIG
; i
++) {
135 if (sigismember((sigset_t
*)&m_in
.sig_set
, i
))
136 sigdelset(&mp
->mp_sigmask
, i
);
142 sigdelset((sigset_t
*) &m_in
.sig_set
, SIGKILL
);
143 sigdelset((sigset_t
*) &m_in
.sig_set
, SIGSTOP
);
144 mp
->mp_sigmask
= (sigset_t
) m_in
.sig_set
;
158 /*===========================================================================*
160 *===========================================================================*/
161 PUBLIC
int do_sigsuspend()
163 mp
->mp_sigmask2
= mp
->mp_sigmask
; /* save the old mask */
164 mp
->mp_sigmask
= (sigset_t
) m_in
.sig_set
;
165 sigdelset(&mp
->mp_sigmask
, SIGKILL
);
166 sigdelset(&mp
->mp_sigmask
, SIGSTOP
);
167 mp
->mp_flags
|= SIGSUSPENDED
;
172 /*===========================================================================*
174 *===========================================================================*/
175 PUBLIC
int do_sigreturn()
177 /* A user signal handler is done. Restore context and check for
178 * pending unblocked signals.
183 mp
->mp_sigmask
= (sigset_t
) m_in
.sig_set
;
184 sigdelset(&mp
->mp_sigmask
, SIGKILL
);
185 sigdelset(&mp
->mp_sigmask
, SIGSTOP
);
187 r
= sys_sigreturn(who_e
, (struct sigmsg
*) m_in
.sig_context
);
192 /*===========================================================================*
194 *===========================================================================*/
197 /* Perform the kill(pid, signo) system call. */
199 return check_sig(m_in
.pid
, m_in
.sig_nr
, FALSE
/* ksig */);
202 /*===========================================================================*
204 *===========================================================================*/
205 PUBLIC
int ksig_pending()
207 /* Certain signals, such as segmentation violations originate in the kernel.
208 * When the kernel detects such signals, it notifies the PM to take further
209 * action. The PM requests the kernel to send messages with the process
210 * slot and bit map for all signaled processes. The File System, for example,
211 * uses this mechanism to signal writing on broken pipes (SIGPIPE).
213 * The kernel has notified the PM about pending signals. Request pending
214 * signals until all signals are handled. If there are no more signals,
215 * NONE is returned in the process number field.
217 endpoint_t proc_nr_e
;
222 /* get an arbitrary pending signal */
223 if((r
=sys_getksig(&proc_nr_e
, &sig_map
)) != OK
)
224 panic("sys_getksig failed: %d", r
);
225 if (NONE
== proc_nr_e
) { /* stop if no more pending signals */
229 if(pm_isokendpt(proc_nr_e
, &proc_nr_p
) != OK
)
230 panic("sys_getksig strange process: %d", proc_nr_e
);
231 handle_ksig(proc_nr_e
, sig_map
); /* handle the received signal */
232 /* If the process still exists to the kernel after the signal
233 * has been handled ...
235 if ((mproc
[proc_nr_p
].mp_flags
& (IN_USE
| EXITING
)) == IN_USE
)
237 if((r
=sys_endksig(proc_nr_e
)) != OK
) /* ... tell kernel it's done */
238 panic("sys_endksig failed: %d", r
);
242 return(SUSPEND
); /* prevents sending reply */
245 /*===========================================================================*
247 *===========================================================================*/
248 PRIVATE
void handle_ksig(proc_nr_e
, sig_map
)
252 register struct mproc
*rmp
;
256 if(pm_isokendpt(proc_nr_e
, &proc_nr
) != OK
|| proc_nr
< 0) {
257 printf("PM: handle_ksig: %d?? not ok\n", proc_nr_e
);
260 rmp
= &mproc
[proc_nr
];
261 if ((rmp
->mp_flags
& (IN_USE
| EXITING
)) != IN_USE
) {
263 printf("PM: handle_ksig: %d?? exiting / not in use\n", proc_nr_e
);
267 proc_id
= rmp
->mp_pid
;
268 mp
= &mproc
[0]; /* pretend signals are from PM */
269 mp
->mp_procgrp
= rmp
->mp_procgrp
; /* get process group right */
271 /* Check each bit in turn to see if a signal is to be sent. Unlike
272 * kill(), the kernel may collect several unrelated signals for a
273 * process and pass them to PM in one blow. Thus loop on the bit
274 * map. For SIGVTALRM and SIGPROF, see if we need to restart a
275 * virtual timer. For SIGINT, SIGWINCH and SIGQUIT, use proc_id 0
276 * to indicate a broadcast to the recipient's process group. For
277 * SIGKILL, use proc_id -1 to indicate a systemwide broadcast.
279 for (i
= 1; i
< _NSIG
; i
++) {
280 if (!sigismember(&sig_map
, i
)) continue;
282 printf("PM: sig %d for %d from kernel\n",
289 id
= 0; break; /* broadcast to process group */
292 check_vtimer(proc_nr
, i
);
298 check_sig(id
, i
, TRUE
/* ksig */);
301 /* If SIGNDELAY is set, an earlier sys_stop() failed because the process was
302 * still sending, and the kernel hereby tells us that the process is now done
303 * with that. We can now try to resume what we planned to do in the first
304 * place: set up a signal handler. However, the process's message may have
305 * been a call to PM, in which case the process may have changed any of its
306 * signal settings. The process may also have forked, exited etcetera.
308 if (sigismember(&sig_map
, SIGNDELAY
) && (rmp
->mp_flags
& DELAY_CALL
)) {
309 rmp
->mp_flags
&= ~DELAY_CALL
;
311 if (rmp
->mp_flags
& (FS_CALL
| PM_SIG_PENDING
))
312 panic("handle_ksig: bad process state");
314 /* Process as many normal signals as possible. */
317 if (rmp
->mp_flags
& DELAY_CALL
)
318 panic("handle_ksig: multiple delay calls?");
322 /*===========================================================================*
324 *===========================================================================*/
325 PUBLIC
int do_pause()
327 /* Perform the pause() system call. */
329 mp
->mp_flags
|= PAUSED
;
333 /*===========================================================================*
335 *===========================================================================*/
336 PUBLIC
void sig_proc(rmp
, signo
, trace
, ksig
)
337 register struct mproc
*rmp
; /* pointer to the process to be signaled */
338 int signo
; /* signal to send to process (1 to _NSIG-1) */
339 int trace
; /* pass signal to tracer first? */
340 int ksig
; /* non-zero means signal comes from kernel */
342 /* Send a signal to a process. Check to see if the signal is to be caught,
343 * ignored, tranformed into a message (for system processes) or blocked.
344 * - If the signal is to be transformed into a message, request the KERNEL to
345 * send the target process a system notification with the pending signal as an
347 * - If the signal is to be caught, request the KERNEL to push a sigcontext
348 * structure and a sigframe structure onto the catcher's stack. Also, KERNEL
349 * will reset the program counter and stack pointer, so that when the process
350 * next runs, it will be executing the signal handler. When the signal handler
351 * returns, sigreturn(2) will be called. Then KERNEL will restore the signal
352 * context from the sigcontext structure.
353 * If there is insufficient stack space, kill the process.
355 int r
, slot
, badignore
;
357 slot
= (int) (rmp
- mproc
);
358 if ((rmp
->mp_flags
& (IN_USE
| EXITING
)) != IN_USE
) {
359 printf("PM: signal %d sent to exiting process %d\n", signo
, slot
);
363 if (trace
== TRUE
&& rmp
->mp_tracer
!= NO_TRACER
&& signo
!= SIGKILL
) {
364 /* Signal should be passed to the debugger first.
365 * This happens before any checks on block/ignore masks; otherwise,
366 * the process itself could block/ignore debugger signals.
369 sigaddset(&rmp
->mp_sigtrace
, signo
);
371 if (!(rmp
->mp_flags
& STOPPED
))
372 stop_proc(rmp
, signo
); /* a signal causes it to stop */
377 if (rmp
->mp_flags
& FS_CALL
) {
378 sigaddset(&rmp
->mp_sigpending
, signo
);
380 if (!(rmp
->mp_flags
& PM_SIG_PENDING
)) {
381 /* No delay calls: FS_CALL implies the process called us. */
382 if ((r
= sys_stop(rmp
->mp_endpoint
)) != OK
)
383 panic("sys_stop failed: %d", r
);
385 rmp
->mp_flags
|= PM_SIG_PENDING
;
391 /* some signals cannot be safely ignored */
392 badignore
= ksig
&& sigismember(&noign_sset
, signo
) && (
393 sigismember(&rmp
->mp_ignore
, signo
) ||
394 sigismember(&rmp
->mp_sigmask
, signo
) ||
395 sigismember(&rmp
->mp_sig2mess
, signo
));
397 if (!badignore
&& sigismember(&rmp
->mp_ignore
, signo
)) {
398 /* Signal should be ignored. */
401 if (!badignore
&& sigismember(&rmp
->mp_sigmask
, signo
)) {
402 /* Signal should be blocked. */
403 sigaddset(&rmp
->mp_sigpending
, signo
);
406 if (!badignore
&& sigismember(&rmp
->mp_sig2mess
, signo
)) {
407 /* Mark event pending in process slot and send notification. */
408 sigaddset(&rmp
->mp_sigpending
, signo
);
409 notify(rmp
->mp_endpoint
);
413 if ((rmp
->mp_flags
& STOPPED
) && signo
!= SIGKILL
) {
414 /* If the process is stopped for a debugger, do not deliver any signals
415 * (except SIGKILL) in order not to confuse the debugger. The signals
416 * will be delivered using the check_pending() calls in do_trace().
418 sigaddset(&rmp
->mp_sigpending
, signo
);
422 if (!badignore
&& sigismember(&rmp
->mp_catch
, signo
)) {
423 /* Signal is caught. First interrupt the process's current call, if
424 * applicable. This may involve a roundtrip to FS, in which case we'll
425 * have to check back later.
427 if (!(rmp
->mp_flags
& UNPAUSED
)) {
430 if (!(rmp
->mp_flags
& UNPAUSED
)) {
431 /* not yet unpaused; continue later */
432 sigaddset(&rmp
->mp_sigpending
, signo
);
438 /* Then send the actual signal to the process, by setting up a signal
441 if (sig_send(rmp
, signo
))
444 /* We were unable to spawn a signal handler. Kill the process. */
446 else if (!badignore
&& sigismember(&ign_sset
, signo
)) {
447 /* Signal defaults to being ignored. */
451 /* Terminate process */
452 rmp
->mp_sigstatus
= (char) signo
;
453 if (sigismember(&core_sset
, signo
)) {
454 printf("PM: coredump signal %d for %d / %s\n", signo
, rmp
->mp_pid
,
456 exit_proc(rmp
, 0, TRUE
/*dump_core*/);
459 exit_proc(rmp
, 0, FALSE
/*dump_core*/);
463 /*===========================================================================*
465 *===========================================================================*/
466 PUBLIC
int check_sig(proc_id
, signo
, ksig
)
467 pid_t proc_id
; /* pid of proc to sig, or 0 or -1, or -pgrp */
468 int signo
; /* signal to send to process (0 to _NSIG-1) */
469 int ksig
; /* non-zero means signal comes from kernel */
471 /* Check to see if it is possible to send a signal. The signal may have to be
472 * sent to a group of processes. This routine is invoked by the KILL system
473 * call, and also when the kernel catches a DEL or other signal.
476 register struct mproc
*rmp
;
477 int count
; /* count # of signals sent */
480 if (signo
< 0 || signo
>= _NSIG
) return(EINVAL
);
482 /* Return EINVAL for attempts to send SIGKILL to INIT alone. */
483 if (proc_id
== INIT_PID
&& signo
== SIGKILL
) return(EINVAL
);
485 /* Search the proc table for processes to signal.
486 * (See forkexit.c about pid magic.)
490 for (rmp
= &mproc
[0]; rmp
< &mproc
[NR_PROCS
]; rmp
++) {
491 if (!(rmp
->mp_flags
& IN_USE
)) continue;
493 /* Check for selection. */
494 if (proc_id
> 0 && proc_id
!= rmp
->mp_pid
) continue;
495 if (proc_id
== 0 && mp
->mp_procgrp
!= rmp
->mp_procgrp
) continue;
496 if (proc_id
== -1 && rmp
->mp_pid
<= INIT_PID
) continue;
497 if (proc_id
< -1 && rmp
->mp_procgrp
!= -proc_id
) continue;
499 /* Do not kill servers and drivers when broadcasting SIGKILL. */
500 if (proc_id
== -1 && signo
== SIGKILL
&&
501 (rmp
->mp_flags
& PRIV_PROC
)) continue;
503 /* Check for permission. */
504 if (mp
->mp_effuid
!= SUPER_USER
505 && mp
->mp_realuid
!= rmp
->mp_realuid
506 && mp
->mp_effuid
!= rmp
->mp_realuid
507 && mp
->mp_realuid
!= rmp
->mp_effuid
508 && mp
->mp_effuid
!= rmp
->mp_effuid
) {
514 if (signo
== 0 || (rmp
->mp_flags
& EXITING
)) continue;
516 /* 'sig_proc' will handle the disposition of the signal. The
517 * signal may be caught, blocked, ignored, or cause process
518 * termination, possibly with core dump.
520 sig_proc(rmp
, signo
, TRUE
/*trace*/, ksig
);
522 if (proc_id
> 0) break; /* only one process being signaled */
525 /* If the calling process has killed itself, don't reply. */
526 if ((mp
->mp_flags
& (IN_USE
| EXITING
)) != IN_USE
) return(SUSPEND
);
527 return(count
> 0 ? OK
: error_code
);
530 /*===========================================================================*
532 *===========================================================================*/
533 PUBLIC
void check_pending(rmp
)
534 register struct mproc
*rmp
;
536 /* Check to see if any pending signals have been unblocked. Deliver as many
537 * of them as we can, until we have to wait for a reply from VFS first.
539 * There are several places in this file where the signal mask is
540 * changed. At each such place, check_pending() should be called to
541 * check for newly unblocked signals.
546 for (i
= 1; i
< _NSIG
; i
++) {
547 if (sigismember(&rmp
->mp_sigpending
, i
) &&
548 !sigismember(&rmp
->mp_sigmask
, i
)) {
549 sigdelset(&rmp
->mp_sigpending
, i
);
550 sig_proc(rmp
, i
, FALSE
/*trace*/, FALSE
/* ksig */);
552 if (rmp
->mp_flags
& FS_CALL
)
558 /*===========================================================================*
560 *===========================================================================*/
561 PUBLIC
void restart_sigs(rmp
)
564 /* FS has replied to a request from us; do signal-related work.
568 if (rmp
->mp_flags
& (FS_CALL
| EXITING
)) return;
570 if (rmp
->mp_flags
& TRACE_EXIT
) {
571 /* Tracer requested exit with specific exit value */
572 exit_proc(rmp
, rmp
->mp_exitstatus
, FALSE
/*dump_core*/);
574 else if (rmp
->mp_flags
& PM_SIG_PENDING
) {
575 /* We saved signal(s) for after finishing a FS call. Deal with this.
576 * PM_SIG_PENDING remains set to indicate the process is still stopped.
580 /* The process may now be FS-blocked again, because a signal exited the
581 * process or was caught. Restart the process only when this is NOT the
584 if (!(rmp
->mp_flags
& FS_CALL
)) {
585 rmp
->mp_flags
&= ~(PM_SIG_PENDING
| UNPAUSED
);
587 if ((r
= sys_resume(rmp
->mp_endpoint
)) != OK
)
588 panic("sys_resume failed: %d", r
);
593 /*===========================================================================*
595 *===========================================================================*/
596 PRIVATE
void unpause(rmp
)
597 struct mproc
*rmp
; /* which process */
599 /* A signal is to be sent to a process. If that process is hanging on a
600 * system call, the system call must be terminated with EINTR. Possible
601 * calls are PAUSE, WAIT, READ and WRITE, the latter two for pipes and ttys.
602 * First check if the process is hanging on an PM call. If not, tell FS,
603 * so it can check for READs and WRITEs from pipes, ttys and the like.
608 /* If we're already waiting for a delayed call, don't do anything now. */
609 if (rmp
->mp_flags
& DELAY_CALL
)
612 /* Check to see if process is hanging on a PAUSE, WAIT or SIGSUSPEND call. */
613 if (rmp
->mp_flags
& (PAUSED
| WAITING
| SIGSUSPENDED
)) {
614 /* Stop process from running. No delay calls: it called us. */
615 if ((r
= sys_stop(rmp
->mp_endpoint
)) != OK
)
616 panic("sys_stop failed: %d", r
);
618 rmp
->mp_flags
|= UNPAUSED
;
620 /* We interrupt the actual call from sig_send() below. */
624 /* Not paused in PM. Let FS try to unpause the process. */
625 if (!(rmp
->mp_flags
& PM_SIG_PENDING
)) {
626 /* Stop process from running. */
627 r
= sys_delay_stop(rmp
->mp_endpoint
);
629 /* If the process is still busy sending a message, the kernel will give
630 * us EBUSY now and send a SIGNDELAY to the process as soon as sending
634 rmp
->mp_flags
|= DELAY_CALL
;
638 else if (r
!= OK
) panic("sys_stop failed: %d", r
);
640 rmp
->mp_flags
|= PM_SIG_PENDING
;
643 m
.m_type
= PM_UNPAUSE
;
644 m
.PM_PROC
= rmp
->mp_endpoint
;
649 vm_notify_sig_wrapper(rmp
->mp_endpoint
);
652 /*===========================================================================*
654 *===========================================================================*/
655 PRIVATE
int sig_send(rmp
, signo
)
656 struct mproc
*rmp
; /* what process to spawn a signal handler in */
657 int signo
; /* signal to send to process (1 to _NSIG-1) */
659 /* The process is supposed to catch this signal. Spawn a signal handler.
660 * Return TRUE if this succeeded, FALSE otherwise.
662 struct sigmsg sigmsg
;
664 int r
, sigflags
, slot
;
666 if (!(rmp
->mp_flags
& UNPAUSED
))
667 panic("sig_send: process not unpaused");
669 sigflags
= rmp
->mp_sigact
[signo
].sa_flags
;
670 slot
= (int) (rmp
- mproc
);
672 if (rmp
->mp_flags
& SIGSUSPENDED
)
673 sigmsg
.sm_mask
= rmp
->mp_sigmask2
;
675 sigmsg
.sm_mask
= rmp
->mp_sigmask
;
676 sigmsg
.sm_signo
= signo
;
677 sigmsg
.sm_sighandler
=
678 (vir_bytes
) rmp
->mp_sigact
[signo
].sa_handler
;
679 sigmsg
.sm_sigreturn
= rmp
->mp_sigreturn
;
680 rmp
->mp_sigmask
|= rmp
->mp_sigact
[signo
].sa_mask
;
682 if (sigflags
& SA_NODEFER
)
683 sigdelset(&rmp
->mp_sigmask
, signo
);
685 sigaddset(&rmp
->mp_sigmask
, signo
);
687 if (sigflags
& SA_RESETHAND
) {
688 sigdelset(&rmp
->mp_catch
, signo
);
689 rmp
->mp_sigact
[signo
].sa_handler
= SIG_DFL
;
691 sigdelset(&rmp
->mp_sigpending
, signo
);
693 if(vm_push_sig(rmp
->mp_endpoint
, &cur_sp
) != OK
)
696 sigmsg
.sm_stkptr
= cur_sp
;
698 /* Ask the kernel to deliver the signal */
699 r
= sys_sigsend(rmp
->mp_endpoint
, &sigmsg
);
701 panic("sys_sigsend failed: %d", r
);
703 /* Was the process suspended in PM? Then interrupt the blocking call. */
704 if (rmp
->mp_flags
& (PAUSED
| WAITING
| SIGSUSPENDED
)) {
705 rmp
->mp_flags
&= ~(PAUSED
| WAITING
| SIGSUSPENDED
);
707 setreply(slot
, EINTR
);
710 /* Was the process stopped just for this signal? Then resume it. */
711 if ((rmp
->mp_flags
& (PM_SIG_PENDING
| UNPAUSED
)) == UNPAUSED
) {
712 rmp
->mp_flags
&= ~UNPAUSED
;
714 if ((r
= sys_resume(rmp
->mp_endpoint
)) != OK
)
715 panic("sys_resume failed: %d", r
);
721 /*===========================================================================*
722 * vm_notify_sig_wrapper *
723 *===========================================================================*/
724 PUBLIC
void vm_notify_sig_wrapper(endpoint_t ep
)
726 /* get IPC's endpoint,
727 * the reason that we directly get the endpoint
728 * instead of from DS server is that otherwise
729 * it will cause deadlock between PM, VM and DS.
732 endpoint_t ipc_ep
= 0;
734 for (rmp
= &mproc
[0]; rmp
< &mproc
[NR_PROCS
]; rmp
++) {
735 if (!(rmp
->mp_flags
& IN_USE
))
737 if (!strcmp(rmp
->mp_name
, "ipc")) {
738 ipc_ep
= rmp
->mp_endpoint
;
739 vm_notify_sig(ep
, ipc_ep
);