mirror of
https://github.com/tailscale/tailscale.git
synced 2026-11-30 05:22:44 -08:00
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:
1 parent
02de76ba62
commit
8d43ba6737
1 file changed
+7
-1
@@ -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()
|
||||
|
||||
Reference in new issue
Block a user