46 shows t inys main routine t iny is an iterative

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: . ¯ ¯ Since servers typically run for long periods of time, we must include a SIGCHLD handler that reaps zombie children (lines 8–14). Since SIGCHLD signals are blocked while the SIGCHLD handler is executing, and since Unix signals are not queued, the SIGCHLD handler must be prepared to reap multiple zombie children. Notice that the parent and the child close their respective copies of connfd (lines 39 and 36 respectively). This especially important for the parent, which must close its copy of the connected descriptor to avoid a memory leak that will eventually crash the system. 640 data transfers client 1 clientfd data transfers CHAPTER 12. NETWORK PROGRAMMING child 1 connfd(4) listenfd(3) server client 2 clientfd child 2 connfd(5) Figure 12.33: Server forks another child to service the new client. ¯ Because of the reference count in the socket’s file table entry (Figure 12.21), the socket will not be closed until both the parent’s and child’s copies of connfd are closed. Discussion Of the concurrent-server designs that we will study in this section, process-based designs are by...
View Full Document

This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.

Ask a homework question - tutors are online