6 nonlocal jumps 439 codeecfsetjmpc 1 2 3 4 5 6 7 8 9

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: n sends signal number sig to process pid. If pid is less than zero, than kill sends signal sig to every process in process group abs(pid). Figure 8.25 shows an example of a parent that uses the kill function to send a SIGKILL signal to its child. Sending Signals With the alarm Function A process can send SIGALRM signals to itself by calling the alarm function. #include <unistd.h> unsigned int alarm(unsigned int secs); returns: remaining secs of previous alarm, or 0 if no previous alarm The alarm function arranges for the kernel to send a SIGALRM signal to the calling process in secs seconds. If secs is zero, then no new alarm is scheduled. In any event, the call to alarm cancels any pending alarms, and returns the number of seconds remaining until any pending alarm was due to be delivered (had 426 CHAPTER 8. EXCEPTIONAL CONTROL FLOW code/ecf/kill.c 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 #include "csapp.h" int main() { pid_t pid; /* child sleeps until SIGKILL signal received, then dies */ if ((pid = Fork()) == 0) { Pause(); /* wait for a signal to arrive */ pr...
View Full Document

Ask a homework question - tutors are online