Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,10 @@ final class ManifestWatcher: @unchecked Sendable {

deinit {
debounceWork?.cancel()
source?.cancel()
if fileDescriptor >= 0 {
if source != nil {
// Cancel handler will close the fd — do not also close it here.
source?.cancel()
} else if fileDescriptor >= 0 {
close(fileDescriptor)
}
}
Expand Down
14 changes: 12 additions & 2 deletions crates/pu-engine/src/pty_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,14 @@ impl NativePtyHost {
unsafe { libc::read(read_fd, tmp.as_mut_ptr() as *mut _, tmp.len()) };
if n > 0 {
read_buf.write(&tmp[..n as usize]);
} else if n == 0 {
break; // EOF
} else {
break; // EOF or error
let err = std::io::Error::last_os_error();
if err.kind() == std::io::ErrorKind::Interrupted {
continue; // EINTR — retry
}
break; // Real error
}
}
});
Expand Down Expand Up @@ -283,7 +289,11 @@ impl NativePtyHost {
libc::write(fd, data[offset..].as_ptr() as *const _, data.len() - offset)
};
if n < 0 {
return Err(std::io::Error::last_os_error());
let err = std::io::Error::last_os_error();
if err.kind() == std::io::ErrorKind::Interrupted {
continue; // EINTR — retry
}
return Err(err);
}
offset += n as usize;
}
Expand Down
Loading