Terminal I/O Functions

Terminal I/O interfaces deal with a general terminal interface for controlling asynchronous communications ports, as shown in the following table.

Table 5-5 Terminal I/O Interfaces

Interface Name Purpose

tcgetattr(3C), tcsetattr(3C)

Get and set terminal attributes

tcsendbreak(3C), tcdrain(3C), tcflush(3C), tcflow(3C)

Perform line control interfaces

cfgetospeed(3C), cfgetispeed(3C), cfsetispeed(3C), cfsetospeed(3C)

Get and set baud rate

tcsetpgrp(3C)

Get and set terminal foreground process group ID

tcgetsid(3C)

Get terminal session ID

The following example shows how the server dissociates from the controlling terminal of its invoker in the non-DEBUG mode of operation.

Example 5-4 Dissociating From the Controlling Terminal

(void) close(0);
(void) close(1);
(void) close(2);
(void) open("/", O_RDONLY);
(void) dup2(0, 1);
(void) dup2(0, 2);
setsid();

This operation mode prevents the server from receiving signals from the process group of the controlling terminal. A server cannot send reports of errors to a terminal after the server has dissociated. The dissociated server must log errors with syslog. For more information, see the syslog(3C) man page.