IEEE Standards Interpretation for IEEE Std 1003.1™-1990 IEEE Standard for Information Technology--Portable Operating System Interfaces (POSIX®)
Copyright © 2001 by the Institute of Electrical and Electronics Engineers, Inc. 3 Park Avenue New York, New York 10016-5997 USA All Rights Reserved.
Interpretations are issued to explain and clarify the intent of a standard and do not constitute an alteration to the original standard. In addition, interpretations are not intended to supply consulting information. Permission is hereby granted to download and print one copy of this document. Individuals seeking permission to reproduce and/or distribute this document in its entirety or portions of this document must contact the IEEE Standards Department for the appropriate license. Use of the information contained in this document is at your own risk.
IEEE Standards Department Copyrights and Permissions 445 Hoes Lane, Piscataway, New Jersey 08855-1331, USA
Interpretation Request #51
Topic: cfsetospeed() Relevant Sections: 7 Classification: No change
In the test of cfsetospeed() with speed B0, the test is performed on the controlling terminal rather than the other side of the loopback in order to simulate what a normal application would do. The test expects this to cause a SIGHUP, but on some systems this only occurs when a modem disconnect is detected, not when one is generated, so the test relies on "reflection" of the modem disconnect by the loopback connection on such systems, and if this does not happen the test fails. X/Open believes POSIX says that SIGHUP is generated when disconnected is detected and not before.
Modem disconnect is a function that is initiated when the signal that indicates continuity of the serial communications link is interrupted, either because the asynchronous serial communications port at the opposite end of a serial communications link ceases to maintain the signal or because the integrity of the communications link is lost for some other reason.
When the asynchronous serial communications port associated with a controlling terminal detects that the connection has been lost it causes the behavior associated with modem disconnect to occur, including the generation of a SIGHUP signal.
The precise physical nature of the indicator of communications continuity depends on the communications protocol that is in use and is not specified by IEEE Std 1003.1-1990.
Setting a terminal's output speed terminal to B0 causes the associated asynchronous serial communications port to interrupt its continuity signal ("the modem control lines shall no longer be asserted": page 144, lines 624-625). If the local terminal is the controlling terminal for a session, a SIGHUP must be generated for the controlling process if and when the asynchronous serial communications port at the other end of the connection responds by interrupting its own continuity signal. It is unspecified whether a modem disconnect is detected immediately when the output baud rate of the local terminal is set to B0. Since this is unspecified, it is conforming (but not required) for the local asynchronous serial communications port to perform a complete communications disconnect when its speed is changed to B0 without monitoring the response from the remote port. In this case the modem disconnect would be performed immediately, and if the local port were a controlling terminal the SIGHUP signal would be generated immediately for the controlling process.
Rationale for Interpretation
Modem control is provided to allow applications to make a clean break when a remote device hangs up. Modem disconnect behavior, including the generation of a SIGHUP signal, is intended to allow a shell to log out a user who is no longer connected. This frees the terminal port to accept a new connection and closes the security risk of leaving a live login connected to a communications port.
These purposes depend on the modem disconnect being initiated as soon as the hardware detects that the connection has been lost. A test suite should not depend on unspecified behavior.
Therefore, it should test modem disconnect by causing the local terminal to be the controlling terminal for a session, and having the remote terminal set its output baud rate to B0. A modem disconnect by the remote terminal must be detected immediately at the local terminal, and SIGHUP must be generated for the controlling process for which the local terminal is the controlling terminal. Note also that the input baud rate must be set to 0 or to B0 when this is done, in case the implementation considers it an error to attempt to set input and output baud rates to different values. See IEEE Std 2003.1-1992, subclause 184.108.40.206.2, assertion 10.
Add a definition of the term "modem disconnect", or refer to another standard for a definition.