Skip to content

Commit 0937208

Browse files
committed
Toggle off the CMSPAR flag when switching to other parity modes
1 parent 7419d10 commit 0937208

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/posix/termios.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,17 +154,29 @@ pub(crate) fn set_parity(termios: &mut Termios, parity: Parity) -> Result<()> {
154154
termios.c_cflag &= !(libc::PARENB | libc::PARODD);
155155
termios.c_iflag &= !libc::INPCK;
156156
termios.c_iflag |= libc::IGNPAR;
157+
#[cfg(any(target_os = "linux", target_os = "android"))]
158+
{
159+
termios.c_iflag &= !libc::CMSPAR;
160+
}
157161
}
158162
Parity::Odd => {
159163
termios.c_cflag |= libc::PARENB | libc::PARODD;
160164
termios.c_iflag |= libc::INPCK;
161165
termios.c_iflag &= !libc::IGNPAR;
166+
#[cfg(any(target_os = "linux", target_os = "android"))]
167+
{
168+
termios.c_iflag &= !libc::CMSPAR;
169+
}
162170
}
163171
Parity::Even => {
164172
termios.c_cflag &= !libc::PARODD;
165173
termios.c_cflag |= libc::PARENB;
166174
termios.c_iflag |= libc::INPCK;
167175
termios.c_iflag &= !libc::IGNPAR;
176+
#[cfg(any(target_os = "linux", target_os = "android"))]
177+
{
178+
termios.c_iflag &= !libc::CMSPAR;
179+
}
168180
}
169181
#[cfg(any(target_os = "linux", target_os = "android"))]
170182
Parity::Mark => {

0 commit comments

Comments
 (0)