|
|
- 5.9 Handling SIGCHLD Signals
- ..............................
- ............................
- solaris % tcpserv02 &
- start server in background
-
- [2] 16939
-
- solaris % tcpcli01 127.0.0.1
- then start client in foreground
-
- hi there
- we type this
-
- hi there
- and this is echoed
-
- ^D
- we type our EOF character
-
- child 16942 terminated
- output by printf in signal handler
-
- accept error: Interrupted system call
- main function aborts
-
- The sequence of steps is as follows:
- 1,We terminate the client by typing our EOF character. The client TCP sends a FIN to the server and the server responds with an ACK.
- [color="Red"]2,The receipt of the FIN delivers an EOF to the child's pending readline. The child terminates.[/color]
- 3,The parent is blocked in its call to accept when the SIGCHLD signal is delivered. The sig_chld function executes (our signal handler), wait fetches the child's PID and termination status, and printf is called from the signal handler. The signal handler returns.
- 4,Since the signal was caught by the parent while the parent was blocked in a slow system call (accept), the kernel causes the accept to return an error of EINTR (interrupted system call). The parent does not handle this error (Figure 5.2), so it aborts.
复制代码
在5.9节中有这样的一段话,特别是我用红色标出来的,我觉得有问题. 因为child调用的是str_echo, str_echo调用的是read的函数,根本没有调用readline,child怎么会pending在readline这个函数上?
我在http://www.unpbook.com/上拿了 ... 调用这个函数. 所以我很困惑!不知道看过这个的兄弟有没有这样的经历?难道是我看错了?
(没有看过的可能不知道我在讲什么) |
|