From 8d43ba67374c7c055c28cd55bf65ddc015d18248 Mon Sep 17 00:00:00 2001 From: Francois Marier Date: Tue, 22 Sep 2026 12:28:32 -0700 Subject: [PATCH] tstest/natlab/vmtest: close unused pipe read FD to avoid leak There are two copies of the read file descriptor (parent & child). Since the parent copy is unused, we can close it after fork. Updates #cleanup Change-Id: Id789e0a04970c9fb8eaeed1f299aa25f29fcf48c Signed-off-by: Francois Marier --- tstest/natlab/vmtest/qemu.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tstest/natlab/vmtest/qemu.go b/tstest/natlab/vmtest/qemu.go index b9d12187f8..18295ac95f 100644 --- a/tstest/natlab/vmtest/qemu.go +++ b/tstest/natlab/vmtest/qemu.go @@ -343,7 +343,13 @@ func (e *Env) startQEMUOnce(name, logPath string, args []string) (*qemuRun, erro qemuLog.Close() return nil, fmt.Errorf("killWithParent: %w", err) } - if err := cmd.Start(); err != nil { + err = cmd.Start() + // Child now has a copy of the pipe's read end. Parent can close its own. + // These were populated by killWithParent prior to Start. + for _, f := range cmd.ExtraFiles { + f.Close() + } + if err != nil { parentPipe.Close() devNull.Close() qemuLog.Close()