19.1 | When we remotely log in to a BSD system using either telnet or rlogin, the ownership of the PTY slave and its permissions are set, as we described in Section 19.3.2. How does this happen?
|
19.2 | Modify the function grantpt from Figure 19.9 to invoke a set-user-ID program to change the ownership and protection of the PTY slave device on a BSD system (similar to what the Solaris version of the grantpt function does).
|
19.3 | Use the pty program to determine the values used by your system to initialize a slave PTY's termios structure and winsize structure.
|
19.4 | Recode the loop function (Figure 19.13) as a single process using either select or poll.
|
19.5 | In the child process after pty_fork returns, standard input, standard output, and standard error are all open for readwrite. Can you change standard input to be read-only and the other two to be write-only?
|
19.6 | In Figure 19.14, identify which process groups are foreground and which are background, and identify the session leaders.
|
19.7 | In Figure 19.14, in what order do the processes terminate when we type the end-of-file character? Verify this with process accounting, if possible.
|
19.8 | The script(1) program normally adds to the beginning of the output file a line with the starting time, and to the end of the output file another line with the ending time. Add these features to the simple shell script that we showed.
|
19.9 | Explain why the contents of the file data are output to the terminal in the following example, when the program ttyname only generates output and never reads its input.
$ cat data a file with two lines
hello,
world
$ pty -i < data ttyname -i says ignore eof on stdin
hello, where did these two lines come from?
world
fd 0: /dev/ttyp5 we expect these three lines from ttyname
fd 1: /dev/ttyp5
fd 2: /dev/ttyp5
|
19.10 | Write a program that calls pty_fork and have the child exec another program that you must write. The new program that the child execs must catch SIGTERM and SIGWINCH. When it catches a signal, the program should print that it did; for the latter signal, it should also print the terminal's window size. Then have the parent process send the SIGTERM signal to the process group of the PTY slave with the ioctl we described in Section 19.7. Read back from the slave to verify that the signal was caught. Follow this with the parent setting the window size of the PTY slave and read back the slave's output again. Have the parent exit and determine whether the slave process also terminates; if so, how does it terminate?
|