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 <[email protected]>
This commit is contained in:
Francois Marier authored and François Marier committed 2026-09-23 13:04:11 -07:00
1 parent 02de76ba62
commit 8d43ba6737
1 file changed
+7 -1
+7 -1
View File
@@ -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()