<p>I am using BSD style pty/tty pairs to implement running a sub shell.  When the user exits the sub shell, how do I detect in the master process that this has occurred?  I am using select(nfds, &amp;read_fds, NULL, NULL, &amp;timeout); with the master pty file descriptor set in the read_fds on the master side.</p>

The subshell is typically created by a
```
fork()
```
of some sort.  The PID of the child is returned to the master, which can check (with
```
waitpid()
```
, perhaps) if it's still running.