diff --git a/src/lib.rs b/src/lib.rs index 0209f79..5a93582 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -77,17 +77,20 @@ fn poll_controller_fd_until_read(raw_fd: RawFd) { if let Err(err) = poll(&mut [poll_fd], PollTimeout::ZERO) { if err == Errno::EINTR || err == Errno::EAGAIN { // we were interrupted, so we should just try again + println!("poll interrupted"); continue; } // we should almost never hit this, but if we do, we should just break out of the loop. this // can happen if Node destroys the terminal before waiting for the child process to go away. + println!("poll error: {}", err); break; } // check if POLLIN is no longer set (i.e. there is no more data to read) if let Some(flags) = poll_fd.revents() { if !flags.contains(PollFlags::POLLIN) { + println!("poll complete"); break; } } @@ -98,6 +101,7 @@ fn poll_controller_fd_until_read(raw_fd: RawFd) { continue; } else { // we have exhausted our attempts, its joever + println!("poll timeout"); break; } } @@ -164,6 +168,7 @@ impl Pty { unsafe { // right before we spawn the child, we should do a bunch of setup // this is all run in the context of the child process + println!("pre_exec"); cmd.pre_exec(move || { // start a new session let err = libc::setsid(); @@ -220,6 +225,7 @@ impl Pty { } // actually spawn the child + println!("spawn"); let mut child = cmd.spawn()?; let pid = child.id(); @@ -243,10 +249,14 @@ impl Pty { thread::spawn(move || { drop(user_fd); + println!("start wait"); let wait_result = child.wait(); + println!("end wait"); // try to wait for the controller fd to be fully read + println!("start poll"); poll_controller_fd_until_read(raw_controller_fd); + println!("end poll"); match wait_result { Ok(status) => {