From 01b0cfe2055e23cf03870d9a9f60648037b4005e Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Mon, 14 Sep 2026 23:30:08 +0200 Subject: tests run on OpenBSD; a tool's error message survives one large write; lock pids beyond 32 bits name no process --- internal/extract/tools.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'internal/extract/tools.go') diff --git a/internal/extract/tools.go b/internal/extract/tools.go index ca6a9b0..f815123 100644 --- a/internal/extract/tools.go +++ b/internal/extract/tools.go @@ -65,17 +65,19 @@ type boundedWriter struct { } func (w *boundedWriter) Write(p []byte) (int, error) { + if room := w.limit - w.total; room > 0 { + // The part of p that still fits is kept even when p overflows, so a + // tool that writes its whole error message in one large write still + // has that message's start to show. + w.buf.Write(p[:min(int64(len(p)), room)]) + } w.total += int64(len(p)) - if w.total > w.limit { - if !w.overflowed { - w.overflowed = true - if w.onOverflow != nil { - w.onOverflow() - } + if w.total > w.limit && !w.overflowed { + w.overflowed = true + if w.onOverflow != nil { + w.onOverflow() } - return len(p), nil } - w.buf.Write(p) return len(p), nil } -- cgit v1.3