Aline discipline (LDISC) is a layer in theterminal subsystem in someUnix-like systems.[1] The terminal subsystem consists of three layers: the upper layer to provide thecharacter device interface, the lower hardware driver to communicate with the hardware orpseudo terminal, and the middle line discipline to implement behavior common to terminal devices.
The line discipline glues the low level device driver code with the high level generic interface routines (such as read(2), write(2) andioctl(2)), and is responsible for implementing the semantics associated with the device.[2] The policy is separated from the device driver so that the same serial hardware driver can be used by devices that require different data handling.
For example, the standard line discipline processes the data it receives from the hardware driver and from applications writing to the device according to the requirements of a terminal on aUnix-like system. On input, it handles special characters such as the interrupt character (typicallyControl-C) and the erase and kill characters (typicallybackspace ordelete, and Control-U, respectively) and, on output, it replaces all theLF characters with aCR/LF sequence.
A serial port could also be used for adial-up Internet connection using a serial modem andPPP. In this case, a PPP line discipline would be used; it would accumulate input data from the serial line into PPP input packets, delivering them to the networking stack rather than to the character device, and would transmit packets delivered to it by the networking stack on the serial line.
SomeUnix-like systems useSTREAMS to implement line disciplines.