Thanks to visit codestin.com
Credit goes to github.com

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
12 changes: 6 additions & 6 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,16 @@ fn main() {
println!("Windows build number: {:?}", build_version);

// let conpty_enabled;
let kernel32_res = unsafe { GetModuleHandleW(&HSTRING::from("kernel32.dll")) };
let kernel32 = kernel32_res.unwrap();
// let kernel32_res = unsafe { GetModuleHandleW(&HSTRING::from("kernel32.dll")) };
// let kernel32 = kernel32_res.unwrap();

let conpty = unsafe { GetProcAddress(kernel32, "CreatePseudoConsole".into_pcstr()) };
match conpty {
Some(_) => {
// let conpty = unsafe { GetProcAddress(kernel32, "CreatePseudoConsole".into_pcstr()) };
match major_version >= 10 && build_version >= 2004 {
true => {
conpty_enabled = "1";
println!("cargo:rustc-cfg=feature=\"conpty\"")
}
None => {
false => {
conpty_enabled = "0";
}
}
Expand Down
30 changes: 16 additions & 14 deletions src/pty/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,9 +462,10 @@ impl PTYProcess {
let process_result = reader_process_rx.recv();
if let Ok(Some(process)) = process_result {
reader_ready.store(true, Ordering::Release);
while reader_alive_rx
let mut alive = reader_alive_rx
.try_recv()
.unwrap_or(true)
.unwrap_or(true);
while alive
{
if !is_eof(process.into(), conout.into()).unwrap() {
match read(true, conout.into(), using_pipes, None) {
Expand All @@ -475,8 +476,12 @@ impl PTYProcess {
reader_out_tx.send(Some(Err(err))).unwrap();
}
}
alive = reader_alive_rx
.try_recv()
.unwrap_or(true);
} else {
reader_out_tx.send(None).unwrap();
alive = false;
}
}
spinlock_clone.store(false, Ordering::Release);
Expand Down Expand Up @@ -772,21 +777,18 @@ impl PTYProcess {
)
.is_ok();

let total_bytes = bytes.assume_init();

if succ {
let is_alive = match self.is_alive() {
Ok(alive) => alive || !self.reader_out_rx.is_empty(),
Err(err) => {
return Err(err);
}
};
let _total_bytes = bytes.assume_init();

if total_bytes == 0 && !is_alive {
succ = false;
let is_alive = match self.is_alive() {
Ok(alive) => {
alive || !self.reader_out_rx.is_empty()
},
Err(err) => {
return Err(err);
}
}
};

succ = succ || is_alive || self.reader_atomic.load(Ordering::Acquire);
Ok(!succ)
}
}
Expand Down
Loading