4
4
use unix:: solarish:: * ;
5
5
6
6
pub unsafe fn cfmakeraw ( termios : * mut :: termios ) {
7
- let mut t = * termios as :: termios ;
8
- t. c_iflag &= !( IMAXBEL
7
+ ( * termios) . c_iflag &= !( IMAXBEL
9
8
| IGNBRK
10
9
| BRKINT
11
10
| PARMRK
@@ -14,10 +13,26 @@ pub unsafe fn cfmakeraw(termios: *mut ::termios) {
14
13
| IGNCR
15
14
| ICRNL
16
15
| IXON ) ;
17
- t. c_oflag &= !OPOST ;
18
- t. c_lflag &= !( ECHO | ECHONL | ICANON | ISIG | IEXTEN ) ;
19
- t. c_cflag &= !( CSIZE | PARENB ) ;
20
- t. c_cflag |= CS8 ;
16
+ ( * termios) . c_oflag &= !OPOST ;
17
+ ( * termios) . c_lflag &= !( ECHO | ECHONL | ICANON | ISIG | IEXTEN ) ;
18
+ ( * termios) . c_cflag &= !( CSIZE | PARENB ) ;
19
+ ( * termios) . c_cflag |= CS8 ;
20
+
21
+ // By default, most software expects a pending read to block until at
22
+ // least one byte becomes available. As per termio(7I), this requires
23
+ // setting the MIN and TIME parameters appropriately.
24
+ //
25
+ // As a somewhat unfortunate artefact of history, the MIN and TIME slots
26
+ // in the control character array overlap with the EOF and EOL slots used
27
+ // for canonical mode processing. Because the EOF character needs to be
28
+ // the ASCII EOT value (aka Control-D), it has the byte value 4. When
29
+ // switching to raw mode, this is interpreted as a MIN value of 4; i.e.,
30
+ // reads will block until at least four bytes have been input.
31
+ //
32
+ // Other platforms with a distinct MIN slot like Linux and FreeBSD appear
33
+ // to default to a MIN value of 1, so we'll force that value here:
34
+ ( * termios) . c_cc [ VMIN ] = 1 ;
35
+ ( * termios) . c_cc [ VTIME ] = 0 ;
21
36
}
22
37
23
38
pub unsafe fn cfsetspeed (
0 commit comments