Class 17: Exceptional Control Flow II (ECF) From last time: * ECF occurs at all levels of a system: * Exceptions * Concurrent processes * Signals * Non-local jumps Todays topics: 1. Process hierarchy 2. Shells 3. Signals 4. Non-local jumps ************************* 1. Unix process hierarchy ************************ * Picture of process hierarchy * Viewed using ps * Unix startup sequence ****************************** 2. Putting it together: Shells ***************************** * shell uses fork, exec, wait, signal to run programs on behalf of the user. * Show simple shell program and use it to motivate the need for signals. ********** 3. Signals ********** * Signal is a small message that notifies a process of an event in the system. * Signal terminology: * Sending a signal * Receiving a signal * Pending signals * Pending and blocked bit vectors * pending: set when delivered and cleared when received * blocked: set by application (sigprocmask), set on entry to signal handler, cleared on exit * Sending signals * Process groups * Sending signals with kill program (fork16) * Sending signals from keyboard (fork17) * Sending signals with kill function (fork12) * Receiving signals * Operational description of receiving signals * Default actions * Installing signal handlers * Example: simple signals (fork13) * Signal handling funkiness * Pending signals are blocked * Pending signals not queued (fork15) * Syscalls can be interrupted * Signal Examples * external.c: Program that reacts to externally generated events (ctrl-c) * internal.c: Program that reacts to internall generated events (SIGALARM) ***************** 4. Nonlocal jumps ***************** * setjmp * longjmp * limitations * restart.c: A program that restarts itself