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 * process_ksig: process a signal an behalf of the kernel
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( int sig_send
, (struct mproc
*rmp
, int signo
) );
38 FORWARD
_PROTOTYPE( void sig_proc_exit
, (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
);
52 svp
= &mp
->mp_sigact
[m_in
.sig_nr
];
53 if ((struct sigaction
*) m_in
.sig_osa
!= (struct sigaction
*) NULL
) {
54 r
= sys_datacopy(PM_PROC_NR
,(vir_bytes
) svp
,
55 who_e
, (vir_bytes
) m_in
.sig_osa
, (phys_bytes
) sizeof(svec
));
56 if (r
!= OK
) return(r
);
59 if ((struct sigaction
*) m_in
.sig_nsa
== (struct sigaction
*) NULL
)
62 /* Read in the sigaction structure. */
63 r
= sys_datacopy(who_e
, (vir_bytes
) m_in
.sig_nsa
,
64 PM_PROC_NR
, (vir_bytes
) &svec
, (phys_bytes
) sizeof(svec
));
65 if (r
!= OK
) return(r
);
67 if (svec
.sa_handler
== SIG_IGN
) {
68 sigaddset(&mp
->mp_ignore
, m_in
.sig_nr
);
69 sigdelset(&mp
->mp_sigpending
, m_in
.sig_nr
);
70 sigdelset(&mp
->mp_catch
, 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
);
75 sigdelset(&mp
->mp_ignore
, m_in
.sig_nr
);
76 sigaddset(&mp
->mp_catch
, m_in
.sig_nr
);
78 mp
->mp_sigact
[m_in
.sig_nr
].sa_handler
= svec
.sa_handler
;
79 sigdelset(&svec
.sa_mask
, SIGKILL
);
80 sigdelset(&svec
.sa_mask
, SIGSTOP
);
81 mp
->mp_sigact
[m_in
.sig_nr
].sa_mask
= svec
.sa_mask
;
82 mp
->mp_sigact
[m_in
.sig_nr
].sa_flags
= svec
.sa_flags
;
83 mp
->mp_sigreturn
= (vir_bytes
) m_in
.sig_ret
;
87 /*===========================================================================*
89 *===========================================================================*/
90 PUBLIC
int do_sigpending()
92 mp
->mp_reply
.reply_mask
= (long) mp
->mp_sigpending
;
96 /*===========================================================================*
98 *===========================================================================*/
99 PUBLIC
int do_sigprocmask()
101 /* Note that the library interface passes the actual mask in sigmask_set,
102 * not a pointer to the mask, in order to save a copy. Similarly,
103 * the old mask is placed in the return message which the library
104 * interface copies (if requested) to the user specified address.
106 * The library interface must set SIG_INQUIRE if the 'act' argument
109 * KILL and STOP can't be masked.
114 mp
->mp_reply
.reply_mask
= (long) mp
->mp_sigmask
;
116 switch (m_in
.sig_how
) {
118 sigdelset((sigset_t
*)&m_in
.sig_set
, SIGKILL
);
119 sigdelset((sigset_t
*)&m_in
.sig_set
, SIGSTOP
);
120 for (i
= 1; i
< _NSIG
; i
++) {
121 if (sigismember((sigset_t
*)&m_in
.sig_set
, i
))
122 sigaddset(&mp
->mp_sigmask
, i
);
127 for (i
= 1; i
< _NSIG
; i
++) {
128 if (sigismember((sigset_t
*)&m_in
.sig_set
, i
))
129 sigdelset(&mp
->mp_sigmask
, i
);
135 sigdelset((sigset_t
*) &m_in
.sig_set
, SIGKILL
);
136 sigdelset((sigset_t
*) &m_in
.sig_set
, SIGSTOP
);
137 mp
->mp_sigmask
= (sigset_t
) m_in
.sig_set
;
151 /*===========================================================================*
153 *===========================================================================*/
154 PUBLIC
int do_sigsuspend()
156 mp
->mp_sigmask2
= mp
->mp_sigmask
; /* save the old mask */
157 mp
->mp_sigmask
= (sigset_t
) m_in
.sig_set
;
158 sigdelset(&mp
->mp_sigmask
, SIGKILL
);
159 sigdelset(&mp
->mp_sigmask
, SIGSTOP
);
160 mp
->mp_flags
|= SIGSUSPENDED
;
165 /*===========================================================================*
167 *===========================================================================*/
168 PUBLIC
int do_sigreturn()
170 /* A user signal handler is done. Restore context and check for
171 * pending unblocked signals.
176 mp
->mp_sigmask
= (sigset_t
) m_in
.sig_set
;
177 sigdelset(&mp
->mp_sigmask
, SIGKILL
);
178 sigdelset(&mp
->mp_sigmask
, SIGSTOP
);
180 r
= sys_sigreturn(who_e
, (struct sigmsg
*) m_in
.sig_context
);
185 /*===========================================================================*
187 *===========================================================================*/
190 /* Perform the kill(pid, signo) system call. */
192 return check_sig(m_in
.pid
, m_in
.sig_nr
, FALSE
/* ksig */);
195 /*===========================================================================*
197 *===========================================================================*/
198 PUBLIC
int do_srv_kill()
200 /* Perform the srv_kill(pid, signo) system call. */
202 /* Only RS is allowed to use srv_kill. */
203 if (mp
->mp_endpoint
!= RS_PROC_NR
)
206 /* Pretend the signal comes from the kernel when RS wants to deliver a signal
207 * to a system process. RS sends a SIGKILL when it wants to perform cleanup.
208 * In that case, ksig == TRUE forces PM to exit the process immediately.
210 return check_sig(m_in
.pid
, m_in
.sig_nr
, TRUE
/* ksig */);
213 /*===========================================================================*
215 *===========================================================================*/
216 PUBLIC
int process_ksig(int proc_nr_e
, int signo
)
218 register struct mproc
*rmp
;
222 if(pm_isokendpt(proc_nr_e
, &proc_nr
) != OK
|| proc_nr
< 0) {
223 printf("PM: process_ksig: %d?? not ok\n", proc_nr_e
);
224 return EDEADSRCDST
; /* process is gone. */
226 rmp
= &mproc
[proc_nr
];
227 if ((rmp
->mp_flags
& (IN_USE
| EXITING
)) != IN_USE
) {
229 printf("PM: process_ksig: %d?? exiting / not in use\n", proc_nr_e
);
231 return EDEADSRCDST
; /* process is gone. */
233 proc_id
= rmp
->mp_pid
;
234 mp
= &mproc
[0]; /* pretend signals are from PM */
235 mp
->mp_procgrp
= rmp
->mp_procgrp
; /* get process group right */
237 /* For SIGVTALRM and SIGPROF, see if we need to restart a
238 * virtual timer. For SIGINT, SIGWINCH and SIGQUIT, use proc_id 0
239 * to indicate a broadcast to the recipient's process group. For
240 * SIGKILL, use proc_id -1 to indicate a systemwide broadcast.
246 id
= 0; break; /* broadcast to process group */
249 check_vtimer(proc_nr
, signo
);
255 check_sig(id
, signo
, TRUE
/* ksig */);
257 /* If SIGSNDELAY is set, an earlier sys_stop() failed because the process was
258 * still sending, and the kernel hereby tells us that the process is now done
259 * with that. We can now try to resume what we planned to do in the first
260 * place: set up a signal handler. However, the process's message may have
261 * been a call to PM, in which case the process may have changed any of its
262 * signal settings. The process may also have forked, exited etcetera.
264 if (signo
== SIGSNDELAY
&& (rmp
->mp_flags
& DELAY_CALL
)) {
265 rmp
->mp_flags
&= ~DELAY_CALL
;
267 if (rmp
->mp_flags
& (FS_CALL
| PM_SIG_PENDING
))
268 panic("process_ksig: bad process state");
270 /* Process as many normal signals as possible. */
273 if (rmp
->mp_flags
& DELAY_CALL
)
274 panic("process_ksig: multiple delay calls?");
277 /* See if the process is still alive */
278 if ((mproc
[proc_nr
].mp_flags
& (IN_USE
| EXITING
)) == IN_USE
) {
279 return OK
; /* signal has been delivered */
282 return EDEADSRCDST
; /* process is gone */
286 /*===========================================================================*
288 *===========================================================================*/
289 PUBLIC
int do_pause()
291 /* Perform the pause() system call. */
293 mp
->mp_flags
|= PAUSED
;
297 /*===========================================================================*
299 *===========================================================================*/
300 PUBLIC
void sig_proc(rmp
, signo
, trace
, ksig
)
301 register struct mproc
*rmp
; /* pointer to the process to be signaled */
302 int signo
; /* signal to send to process (1 to _NSIG-1) */
303 int trace
; /* pass signal to tracer first? */
304 int ksig
; /* non-zero means signal comes from kernel */
306 /* Send a signal to a process. Check to see if the signal is to be caught,
307 * ignored, tranformed into a message (for system processes) or blocked.
308 * - If the signal is to be transformed into a message, request the KERNEL to
309 * send the target process a system notification with the pending signal as an
311 * - If the signal is to be caught, request the KERNEL to push a sigcontext
312 * structure and a sigframe structure onto the catcher's stack. Also, KERNEL
313 * will reset the program counter and stack pointer, so that when the process
314 * next runs, it will be executing the signal handler. When the signal handler
315 * returns, sigreturn(2) will be called. Then KERNEL will restore the signal
316 * context from the sigcontext structure.
317 * If there is insufficient stack space, kill the process.
319 int r
, slot
, badignore
;
321 slot
= (int) (rmp
- mproc
);
322 if ((rmp
->mp_flags
& (IN_USE
| EXITING
)) != IN_USE
) {
323 printf("PM: signal %d sent to exiting process %d\n", signo
, slot
);
327 if (trace
== TRUE
&& rmp
->mp_tracer
!= NO_TRACER
&& signo
!= SIGKILL
) {
328 /* Signal should be passed to the debugger first.
329 * This happens before any checks on block/ignore masks; otherwise,
330 * the process itself could block/ignore debugger signals.
333 sigaddset(&rmp
->mp_sigtrace
, signo
);
335 if (!(rmp
->mp_flags
& STOPPED
))
336 stop_proc(rmp
, signo
); /* a signal causes it to stop */
341 if (rmp
->mp_flags
& FS_CALL
) {
342 sigaddset(&rmp
->mp_sigpending
, signo
);
344 if (!(rmp
->mp_flags
& PM_SIG_PENDING
)) {
345 /* No delay calls: FS_CALL implies the process called us. */
346 if ((r
= sys_stop(rmp
->mp_endpoint
)) != OK
)
347 panic("sys_stop failed: %d", r
);
349 rmp
->mp_flags
|= PM_SIG_PENDING
;
355 /* Handle system signals for system processes first. */
356 if(rmp
->mp_flags
& PRIV_PROC
) {
357 /* System signals have always to go through the kernel first to let it
358 * pick the right signal manager. If PM is the assigned signal manager,
359 * the signal will come back and will actually be processed.
362 sys_kill(rmp
->mp_endpoint
, signo
);
366 /* Print stacktrace if necessary. */
367 if(SIGS_IS_STACKTRACE(signo
)) {
368 sys_sysctl_stacktrace(rmp
->mp_endpoint
);
371 if(!SIGS_IS_TERMINATION(signo
)) {
372 /* Translate every non-termination sys signal into a message. */
374 m
.m_type
= SIGS_SIGNAL_RECEIVED
;
375 m
.SIGS_SIG_NUM
= signo
;
376 asynsend3(rmp
->mp_endpoint
, &m
, AMF_NOREPLY
);
379 /* Exit the process in case of termination system signal. */
380 sig_proc_exit(rmp
, signo
);
385 /* Handle user processes now. See if the signal cannot be safely ignored. */
386 badignore
= ksig
&& sigismember(&noign_sset
, signo
) && (
387 sigismember(&rmp
->mp_ignore
, signo
) ||
388 sigismember(&rmp
->mp_sigmask
, signo
));
390 if (!badignore
&& sigismember(&rmp
->mp_ignore
, signo
)) {
391 /* Signal should be ignored. */
394 if (!badignore
&& sigismember(&rmp
->mp_sigmask
, signo
)) {
395 /* Signal should be blocked. */
396 sigaddset(&rmp
->mp_sigpending
, signo
);
400 if ((rmp
->mp_flags
& STOPPED
) && signo
!= SIGKILL
) {
401 /* If the process is stopped for a debugger, do not deliver any signals
402 * (except SIGKILL) in order not to confuse the debugger. The signals
403 * will be delivered using the check_pending() calls in do_trace().
405 sigaddset(&rmp
->mp_sigpending
, signo
);
408 if (!badignore
&& sigismember(&rmp
->mp_catch
, signo
)) {
409 /* Signal is caught. First interrupt the process's current call, if
410 * applicable. This may involve a roundtrip to FS, in which case we'll
411 * have to check back later.
413 if (!(rmp
->mp_flags
& UNPAUSED
)) {
416 if (!(rmp
->mp_flags
& UNPAUSED
)) {
417 /* not yet unpaused; continue later */
418 sigaddset(&rmp
->mp_sigpending
, signo
);
424 /* Then send the actual signal to the process, by setting up a signal
427 if (sig_send(rmp
, signo
))
430 /* We were unable to spawn a signal handler. Kill the process. */
432 else if (!badignore
&& sigismember(&ign_sset
, signo
)) {
433 /* Signal defaults to being ignored. */
437 /* Terminate process */
438 sig_proc_exit(rmp
, signo
);
441 /*===========================================================================*
443 *===========================================================================*/
444 PRIVATE
void sig_proc_exit(rmp
, signo
)
445 struct mproc
*rmp
; /* process that must exit */
446 int signo
; /* signal that caused termination */
448 rmp
->mp_sigstatus
= (char) signo
;
449 if (sigismember(&core_sset
, signo
)) {
450 if(!(rmp
->mp_flags
& PRIV_PROC
)) {
451 printf("PM: coredump signal %d for %d / %s\n", signo
,
452 rmp
->mp_pid
, rmp
->mp_name
);
453 sys_sysctl_stacktrace(rmp
->mp_endpoint
);
455 exit_proc(rmp
, 0, TRUE
/*dump_core*/);
458 exit_proc(rmp
, 0, FALSE
/*dump_core*/);
462 /*===========================================================================*
464 *===========================================================================*/
465 PUBLIC
int check_sig(proc_id
, signo
, ksig
)
466 pid_t proc_id
; /* pid of proc to sig, or 0 or -1, or -pgrp */
467 int signo
; /* signal to send to process (0 to _NSIG-1) */
468 int ksig
; /* non-zero means signal comes from kernel */
470 /* Check to see if it is possible to send a signal. The signal may have to be
471 * sent to a group of processes. This routine is invoked by the KILL system
472 * call, and also when the kernel catches a DEL or other signal.
475 register struct mproc
*rmp
;
476 int count
; /* count # of signals sent */
479 if (signo
< 0 || signo
>= _NSIG
) return(EINVAL
);
481 /* Return EINVAL for attempts to send SIGKILL to INIT alone. */
482 if (proc_id
== INIT_PID
&& signo
== SIGKILL
) return(EINVAL
);
484 /* Signal RS first when broadcasting SIGTERM. */
485 if (proc_id
== -1 && signo
== SIGTERM
)
486 sys_kill(RS_PROC_NR
, signo
);
488 /* Search the proc table for processes to signal. Start from the end of the
489 * table to analyze core system processes at the end when broadcasting.
490 * (See forkexit.c about pid magic.)
494 for (rmp
= &mproc
[NR_PROCS
-1]; rmp
>= &mproc
[0]; rmp
--) {
495 if (!(rmp
->mp_flags
& IN_USE
)) continue;
497 /* Check for selection. */
498 if (proc_id
> 0 && proc_id
!= rmp
->mp_pid
) continue;
499 if (proc_id
== 0 && mp
->mp_procgrp
!= rmp
->mp_procgrp
) continue;
500 if (proc_id
== -1 && rmp
->mp_pid
<= INIT_PID
) continue;
501 if (proc_id
< -1 && rmp
->mp_procgrp
!= -proc_id
) continue;
503 /* Do not kill servers and drivers when broadcasting SIGKILL. */
504 if (proc_id
== -1 && signo
== SIGKILL
&&
505 (rmp
->mp_flags
& PRIV_PROC
)) continue;
507 /* Disallow lethal signals sent by user processes to sys processes. */
508 if (!ksig
&& SIGS_IS_LETHAL(signo
) && (rmp
->mp_flags
& PRIV_PROC
)) {
513 /* Check for permission. */
514 if (mp
->mp_effuid
!= SUPER_USER
515 && mp
->mp_realuid
!= rmp
->mp_realuid
516 && mp
->mp_effuid
!= rmp
->mp_realuid
517 && mp
->mp_realuid
!= rmp
->mp_effuid
518 && mp
->mp_effuid
!= rmp
->mp_effuid
) {
524 if (signo
== 0 || (rmp
->mp_flags
& EXITING
)) continue;
526 /* 'sig_proc' will handle the disposition of the signal. The
527 * signal may be caught, blocked, ignored, or cause process
528 * termination, possibly with core dump.
530 sig_proc(rmp
, signo
, TRUE
/*trace*/, ksig
);
532 if (proc_id
> 0) break; /* only one process being signaled */
535 /* If the calling process has killed itself, don't reply. */
536 if ((mp
->mp_flags
& (IN_USE
| EXITING
)) != IN_USE
) return(SUSPEND
);
537 return(count
> 0 ? OK
: error_code
);
540 /*===========================================================================*
542 *===========================================================================*/
543 PUBLIC
void check_pending(rmp
)
544 register struct mproc
*rmp
;
546 /* Check to see if any pending signals have been unblocked. Deliver as many
547 * of them as we can, until we have to wait for a reply from VFS first.
549 * There are several places in this file where the signal mask is
550 * changed. At each such place, check_pending() should be called to
551 * check for newly unblocked signals.
556 for (i
= 1; i
< _NSIG
; i
++) {
557 if (sigismember(&rmp
->mp_sigpending
, i
) &&
558 !sigismember(&rmp
->mp_sigmask
, i
)) {
559 sigdelset(&rmp
->mp_sigpending
, i
);
560 sig_proc(rmp
, i
, FALSE
/*trace*/, FALSE
/* ksig */);
562 if (rmp
->mp_flags
& FS_CALL
)
568 /*===========================================================================*
570 *===========================================================================*/
571 PUBLIC
void restart_sigs(rmp
)
574 /* FS has replied to a request from us; do signal-related work.
578 if (rmp
->mp_flags
& (FS_CALL
| EXITING
)) return;
580 if (rmp
->mp_flags
& TRACE_EXIT
) {
581 /* Tracer requested exit with specific exit value */
582 exit_proc(rmp
, rmp
->mp_exitstatus
, FALSE
/*dump_core*/);
584 else if (rmp
->mp_flags
& PM_SIG_PENDING
) {
585 /* We saved signal(s) for after finishing a FS call. Deal with this.
586 * PM_SIG_PENDING remains set to indicate the process is still stopped.
590 /* The process may now be FS-blocked again, because a signal exited the
591 * process or was caught. Restart the process only when this is NOT the
594 if (!(rmp
->mp_flags
& FS_CALL
)) {
595 rmp
->mp_flags
&= ~(PM_SIG_PENDING
| UNPAUSED
);
597 if ((r
= sys_resume(rmp
->mp_endpoint
)) != OK
)
598 panic("sys_resume failed: %d", r
);
603 /*===========================================================================*
605 *===========================================================================*/
606 PRIVATE
void unpause(rmp
)
607 struct mproc
*rmp
; /* which process */
609 /* A signal is to be sent to a process. If that process is hanging on a
610 * system call, the system call must be terminated with EINTR. Possible
611 * calls are PAUSE, WAIT, READ and WRITE, the latter two for pipes and ttys.
612 * First check if the process is hanging on an PM call. If not, tell FS,
613 * so it can check for READs and WRITEs from pipes, ttys and the like.
618 /* If we're already waiting for a delayed call, don't do anything now. */
619 if (rmp
->mp_flags
& DELAY_CALL
)
622 /* Check to see if process is hanging on a PAUSE, WAIT or SIGSUSPEND call. */
623 if (rmp
->mp_flags
& (PAUSED
| WAITING
| SIGSUSPENDED
)) {
624 /* Stop process from running. No delay calls: it called us. */
625 if ((r
= sys_stop(rmp
->mp_endpoint
)) != OK
)
626 panic("sys_stop failed: %d", r
);
628 rmp
->mp_flags
|= UNPAUSED
;
630 /* We interrupt the actual call from sig_send() below. */
634 /* Not paused in PM. Let FS try to unpause the process. */
635 if (!(rmp
->mp_flags
& PM_SIG_PENDING
)) {
636 /* Stop process from running. */
637 r
= sys_delay_stop(rmp
->mp_endpoint
);
639 /* If the process is still busy sending a message, the kernel will give
640 * us EBUSY now and send a SIGSNDELAY to the process as soon as sending
644 rmp
->mp_flags
|= DELAY_CALL
;
648 else if (r
!= OK
) panic("sys_stop failed: %d", r
);
650 rmp
->mp_flags
|= PM_SIG_PENDING
;
653 m
.m_type
= PM_UNPAUSE
;
654 m
.PM_PROC
= rmp
->mp_endpoint
;
659 vm_notify_sig_wrapper(rmp
->mp_endpoint
);
662 /*===========================================================================*
664 *===========================================================================*/
665 PRIVATE
int sig_send(rmp
, signo
)
666 struct mproc
*rmp
; /* what process to spawn a signal handler in */
667 int signo
; /* signal to send to process (1 to _NSIG-1) */
669 /* The process is supposed to catch this signal. Spawn a signal handler.
670 * Return TRUE if this succeeded, FALSE otherwise.
672 struct sigmsg sigmsg
;
674 int r
, sigflags
, slot
;
676 if (!(rmp
->mp_flags
& UNPAUSED
))
677 panic("sig_send: process not unpaused");
679 sigflags
= rmp
->mp_sigact
[signo
].sa_flags
;
680 slot
= (int) (rmp
- mproc
);
682 if (rmp
->mp_flags
& SIGSUSPENDED
)
683 sigmsg
.sm_mask
= rmp
->mp_sigmask2
;
685 sigmsg
.sm_mask
= rmp
->mp_sigmask
;
686 sigmsg
.sm_signo
= signo
;
687 sigmsg
.sm_sighandler
=
688 (vir_bytes
) rmp
->mp_sigact
[signo
].sa_handler
;
689 sigmsg
.sm_sigreturn
= rmp
->mp_sigreturn
;
690 rmp
->mp_sigmask
|= rmp
->mp_sigact
[signo
].sa_mask
;
692 if (sigflags
& SA_NODEFER
)
693 sigdelset(&rmp
->mp_sigmask
, signo
);
695 sigaddset(&rmp
->mp_sigmask
, signo
);
697 if (sigflags
& SA_RESETHAND
) {
698 sigdelset(&rmp
->mp_catch
, signo
);
699 rmp
->mp_sigact
[signo
].sa_handler
= SIG_DFL
;
701 sigdelset(&rmp
->mp_sigpending
, signo
);
703 if(vm_push_sig(rmp
->mp_endpoint
, &cur_sp
) != OK
)
706 sigmsg
.sm_stkptr
= cur_sp
;
708 /* Ask the kernel to deliver the signal */
709 r
= sys_sigsend(rmp
->mp_endpoint
, &sigmsg
);
711 panic("sys_sigsend failed: %d", r
);
713 /* Was the process suspended in PM? Then interrupt the blocking call. */
714 if (rmp
->mp_flags
& (PAUSED
| WAITING
| SIGSUSPENDED
)) {
715 rmp
->mp_flags
&= ~(PAUSED
| WAITING
| SIGSUSPENDED
);
717 setreply(slot
, EINTR
);
720 /* Was the process stopped just for this signal? Then resume it. */
721 if ((rmp
->mp_flags
& (PM_SIG_PENDING
| UNPAUSED
)) == UNPAUSED
) {
722 rmp
->mp_flags
&= ~UNPAUSED
;
724 if ((r
= sys_resume(rmp
->mp_endpoint
)) != OK
)
725 panic("sys_resume failed: %d", r
);
731 /*===========================================================================*
732 * vm_notify_sig_wrapper *
733 *===========================================================================*/
734 PUBLIC
void vm_notify_sig_wrapper(endpoint_t ep
)
736 /* get IPC's endpoint,
737 * the reason that we directly get the endpoint
738 * instead of from DS server is that otherwise
739 * it will cause deadlock between PM, VM and DS.
742 endpoint_t ipc_ep
= 0;
744 for (rmp
= &mproc
[0]; rmp
< &mproc
[NR_PROCS
]; rmp
++) {
745 if (!(rmp
->mp_flags
& IN_USE
))
747 if (!strcmp(rmp
->mp_name
, "ipc")) {
748 ipc_ep
= rmp
->mp_endpoint
;
749 vm_notify_sig(ep
, ipc_ep
);