(
&mut self,
paused: &AtomicBool,
paused_sync: &Barrier,
)
| 310 | } |
| 311 | |
| 312 | fn run( |
| 313 | &mut self, |
| 314 | paused: &AtomicBool, |
| 315 | paused_sync: &Barrier, |
| 316 | ) -> result::Result<(), EpollHelperError> { |
| 317 | let mut helper = EpollHelper::new(&self.kill_evt, &self.pause_evt)?; |
| 318 | helper.add_event(self.input_queue_evt.as_raw_fd(), INPUT_QUEUE_EVENT)?; |
| 319 | helper.add_event(self.output_queue_evt.as_raw_fd(), OUTPUT_QUEUE_EVENT)?; |
| 320 | helper.add_event(self.config_evt.as_raw_fd(), CONFIG_EVENT)?; |
| 321 | if let Some(resize_pipe) = self.resize_pipe.as_ref() { |
| 322 | helper.add_event(resize_pipe.as_raw_fd(), RESIZE_EVENT)?; |
| 323 | } |
| 324 | if let Some(in_file) = self.endpoint.in_file() { |
| 325 | let mut events = epoll::Events::EPOLLIN; |
| 326 | if self.endpoint.is_pty() { |
| 327 | events |= epoll::Events::EPOLLONESHOT; |
| 328 | } |
| 329 | helper.add_event_custom(in_file.as_raw_fd(), FILE_EVENT, events)?; |
| 330 | self.file_event_registered = true; |
| 331 | } |
| 332 | |
| 333 | // In case of PTY, we want to be able to detect a connection on the |
| 334 | // other end of the PTY. This is done by detecting there's no event |
| 335 | // triggered on the epoll, which is the reason why we want the |
| 336 | // epoll_wait() function to return after the timeout expired. |
| 337 | // In case of TTY, we don't expect to detect such behavior, which is |
| 338 | // why we can afford to block until an actual event is triggered. |
| 339 | let (timeout, enable_event_list) = if self.endpoint.is_pty() { |
| 340 | (500, true) |
| 341 | } else { |
| 342 | (-1, false) |
| 343 | }; |
| 344 | helper.run_with_timeout(paused, paused_sync, self, timeout, enable_event_list)?; |
| 345 | |
| 346 | Ok(()) |
| 347 | } |
| 348 | |
| 349 | // This function should be called when the other end of the PTY is |
| 350 | // connected. It verifies if this is the first time it's been invoked |
no test coverage detected