Skip to content

Commit

Permalink
fix: fix build failure with event-stream, rustix, and use-dev-tty
Browse files Browse the repository at this point in the history
  • Loading branch information
aschey committed Dec 15, 2024
1 parent fc8f977 commit f5d48d8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/crossterm_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
continue-on-error: ${{ matrix.can-fail }}
- name: Test no default features with use-dev-tty feature enabled
if: matrix.os != 'windows-2019'
run: cargo test --no-default-features --features "use-dev-tty events bracketed-paste" -- --nocapture --test-threads 1
run: cargo test --no-default-features --features "use-dev-tty events event-stream bracketed-paste" -- --nocapture --test-threads 1
continue-on-error: ${{ matrix.can-fail }}
- name: Test no default features with windows feature enabled
if: matrix.os == 'windows-2019'
Expand Down
15 changes: 10 additions & 5 deletions src/event/source/unix/tty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ impl UnixInternalEventSource {
wake_pipe: WakePipe::new()?,
})
}

#[cfg(feature = "event-stream")]
fn receiver_fd(&self) -> FileDesc {
#[cfg(feature = "libc")]
return FileDesc::new(self.wake_pipe.receiver.as_raw_fd(), false);
#[cfg(not(feature = "libc"))]
return FileDesc::Borrowed(self.wake_pipe.receiver.as_fd());
}
}

/// read_complete reads from a non-blocking file descriptor
Expand Down Expand Up @@ -164,10 +172,7 @@ impl EventSource for UnixInternalEventSource {
}
}
if fds[1].revents & POLLIN != 0 {
#[cfg(feature = "libc")]
let fd = FileDesc::new(self.winch_signal_receiver.as_raw_fd(), false);
#[cfg(not(feature = "libc"))]
let fd = FileDesc::Borrowed(self.winch_signal_receiver.as_fd());
let fd = self.receiver_fd();
// drain the pipe
while read_complete(&fd, &mut [0; 1024])? != 0 {}
// TODO Should we remove tput?
Expand All @@ -185,7 +190,7 @@ impl EventSource for UnixInternalEventSource {

#[cfg(feature = "event-stream")]
if fds[2].revents & POLLIN != 0 {
let fd = FileDesc::new(self.wake_pipe.receiver.as_raw_fd(), false);
let fd = self.receiver_fd();
// drain the pipe
while read_complete(&fd, &mut [0; 1024])? != 0 {}

Expand Down

0 comments on commit f5d48d8

Please sign in to comment.