Sigprocmask func2on 17 carnegie mellon process groups

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: being called in response to an asynchronous interrupt 15 Carnegie Mellon Pending and Blocked Signals   A signal is pending if sent but not yet received   There can be at most one pending signal of any par2cular type   Important: Signals are not queued     If a process has a pending signal of type k, then subsequent signals of type k that are sent to that process are discarded A process can block the receipt of certain signals   Blocked signals can be delivered, but will not be received un2l the signal is unblocked   A pending signal is received at most once 16 Carnegie Mellon Signal Concepts   Kernel maintains pending and blocked bit vectors in the context of each process   pending: represents the set of pending signals     Kernel sets bit k in pending when a signal of type k is delivered Kernel clears bit k in pending when a signal of type k is received   blocked: represents the set of blocked signals   Can be set and cleared by using the sigprocmask func2on 17 Carnegie Mellon Process Groups   Every process belongs to exactly one process group pid=10 pgid=10 pid=20 pgid=20 Back ­ ground job #1 Fore ­ ground job Child pid=21 pgid=20 Child pid=22 pgid=20 Foreground process group 20 Shell pid=32 pgid=32 Background process group 32 Back ­ ground job #2 pid=40 pgid=40 Background process group 40 getpgrp() Return process group of current process setpgid() Change process group of a process 18 Carnegie Mellon Sending Signals with /bin/kill Program     /bin/kill program sends arbitrary signal to a process or process group Examples   /bin/kill –9 24818 Send SIGKILL to process 24818   /bin/kill –9 –24817 Send SIGKILL to every process in process group 24817 linux> ./forks 16 Child1: pid=24818 pgrp=24817 Child2: pid=24819 pgrp=24817 linux> ps PID TTY TIME CMD 24788 pts/2 00:00:00 tcsh 24818 pts/2 00:00:02 forks 24819 pts/2 00:00:02 forks 24820 pts/2 00:00:00 ps linux> /bin/kill -9 -24817 linux> ps PID TTY TIME CMD 24788 pts/2 00:00:00 tcsh 24823 pts/2 00:00:00 ps linux> 19 Carnegie Mellon Sending Signals from the Keyboard   Typing ctrl ­c (ctrl ­z) sends a SIGINT (SIGTSTP) to every job in the foreground process group.   SIGINT – default ac2on is to terminate each process   SIGTSTP – default ac2on is to stop (suspend) each process pid=10 pgid=10 pid=20 pgid=20 Back ­ ground job #1 Fore ­ ground job Child pid=21 pgid=20 Shell Child pid=32 pgid=32 Background process group 32 Back ­ ground job #2 pid=40 pgid=40 Background process group 40 pid=22 pgid=20 Foreground process group 20 20 Carnegie Mellon Example of ctrl-c and ctrl-z bluefish> ./forks 17 Child: pid=28108 pgrp=28107 Parent: pid=28107 pgrp=28107 <types ctrl-z> Suspended bluefish> ps w PID TTY STAT TIME COMMAND 27699 pts/8 Ss 0:00 -tcsh 28107 pts/8 T 0:01 ./forks 17 28...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online