Skip to content

Commit ab8a10a

Browse files
committed
Fix false shutdown in stdin EOF monitor
The stdin monitor thread set the shutdown flag after a single read call, regardless of the result. If a parent process wrote to stdin without closing it, read returned Ok(1) and falsely triggered a graceful shutdown. Now the thread loops until actual EOF (Ok(0)) or an error before signaling shutdown.
1 parent bd3b38b commit ab8a10a

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

rewatch/src/watcher.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,12 @@ async fn async_watch(
227227
if !std::io::stdin().is_terminal() {
228228
std::thread::spawn(move || {
229229
let mut buf = [0u8; 1];
230-
// This blocks until EOF (Ok(0)) or an error occurs.
231-
let _ = std::io::stdin().read(&mut buf);
230+
loop {
231+
match std::io::stdin().read(&mut buf) {
232+
Ok(0) | Err(_) => break,
233+
Ok(_) => continue,
234+
}
235+
}
232236
stdin_closed.store(true, Ordering::Relaxed);
233237
});
234238
}

0 commit comments

Comments
 (0)