Fix busy loop in `tart exec -i` after piped stdin reaches EOF (#1281)

Unregister the stdin readabilityHandler when availableData returns empty:
a closed pipe fd stays permanently readable, so Foundation re-invokes the
handler in a tight loop (fstat + zero-byte read) at 100% of one core for
the rest of the command's lifetime.

Fixes #1280

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Nikolai Tillmann 2026-07-17 05:56:27 -07:00 committed by GitHub
parent 9e6e59b379
commit 512c1c3630
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 0 deletions

View File

@ -129,6 +129,11 @@ struct Exec: AsyncParsableCommand {
let data = handle.availableData
if data.isEmpty {
// EOF: unregister the handler, otherwise the fd stays permanently
// "readable" and Foundation re-invokes us in a tight loop, burning
// 100% of a core for the rest of the command's lifetime
handle.readabilityHandler = nil
continuation.finish()
} else {
continuation.yield(data)