April 10, 2006
Coverage: [USP] Chapter 11
Discussed Solutions to Exam 3
Basic Shell Setup
(courtesy [ATT])
see [USP] §11.1-§11.3 for more details
Signal Handling in the Foreground
- a <ctrl-c> should not cause the shell to exit
- shell should ignore SIGINT and SIGQUIT
and block them
- since child should be able to be terminated, child
must set the handlers for SIGINT and SIGQUIT
back to the default before execing
- ush3.c
- improvement in ush4.c
- shell should not just ignore SIGINT
- furthermore, shell should only block SIGINT
and SIGQUIT when absolutely necessary
- if shell (parent) receives a SIGINT,
parent clears the input line and returns to prompt through
siglongjump
- child (command) should not do this
- child should take the default action, which is to exit
- parent blocks the signal before the fork
- child restores the default action prior to unblocking
- done by default with execvp
- child cannot wait for this feature in execvp
- a signal may come in between unblocking the signal
and the call to execvp
- William Kimball asks `why not just remove the if statement
entirely from the child?'
- why is wait now at the top of the loop?
References
[USP] K. A. Robbins and S. Robbins. UNIX Systems Programming: Concurrency,
Communication, and Threads. Prentice Hall, 2003