Installation guide

9 This read() call blocks, pending the appearance of modem signals.
10 Turns off timer; the connection with the remote system has been
established.
Example D–3 demonstrates how a DIGITAL UNIX application interacts
with a modem for incoming calls. Error checking of the return values of the
system calls is purposely omitted to simplify the example.
Example D–3: Modem Control for Incoming Calls (DIGITAL UNIX)
int fd;
int lined;
struct termios tty_termios;
1
fd = open(ttyname,O_RDWR | O_NONBLOCK); 2
flags = fcntl(fd, F_GETFL)
fcntl(fd, F_SETFL, flags & ~O_NONBLOCK)
3
setsid(); 4
ioctl(0, TIOCSCTTY, 0); 5
lined = 0;
ioctl(0, TIOCSETD, &lined);
6
tcgetattr(fd,&tty_termios); 7
tty_termios.c_cflag &= ~CLOCAL; 8
tty_termios.c_cflag &= ~CBAUD;
tty_termios.c_cflag |= B2400;
9
tcsetattr(fd,TCSANOW,&tty_termios); 10
for (;;) {
write(fd,"\r\nlogin: ",9);
11
read(fd,buffer,count); 12
if (valid_login_name(buffer))
execl("/usr/bin/login",buffer);
13
}
1 Contains information about the serial line that can be inspected and
altered using the POSIX tcgetattr() and tcsetattr() library
routines.
2 Opens the terminal line. The CLOCAL flag is usually set by default,
allowing you to ignore modem status lines. Use O_NONBLOCK in case
CLOCAL is not set.
3 Turns off O_NONBLOCK; you do not need it.
4 Creates a new session, becomes session leader for new session, and
becomes process leader for new process group.
5 Sets the controlling terminal.
6 Sets the line discipline to 0 (POSIX).
7 Gets current line attributes.
8 Turns off CLOCAL for a modem.
Differences Between DIGITAL UNIX and ULTRIX Terminal Modem Control D–3