Fix `ioctl` call failing on 32 bit architecture (#1011)

This commit is contained in:
Christian Duerr 2018-01-08 22:49:01 +00:00 committed by GitHub
parent bd9123e7df
commit 02953c2812
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -113,10 +113,12 @@ fn openpty(rows: u8, cols: u8) -> (c_int, c_int) {
/// Really only needed on BSD, but should be fine elsewhere
fn set_controlling_terminal(fd: c_int) {
let res = unsafe {
// Cross platform issue because on linux this is u64 as u64 (does nothing)
// But on macos this is u32 as u64, asking for u64::from(u32)
// TIOSCTTY changes based on platform and the `ioctl` call is different
// based on architecture (32/64). So a generic cast is used to make sure
// there are no issues. To allow such a generic cast the clippy warning
// is disabled.
#[cfg_attr(feature = "clippy", allow(cast_lossless))]
libc::ioctl(fd, TIOCSCTTY as u64, 0)
libc::ioctl(fd, TIOCSCTTY as _, 0)
};
if res < 0 {