fortify: keep external files alive
All checks were successful
Test / Create distribution (push) Successful in 19s
Test / Run NixOS test (push) Successful in 3m10s

This should eliminate sporadic failures, like the known double close in "seccomp".

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2025-02-23 03:24:37 +09:00
parent 2e7e160683
commit eda4d612c2
6 changed files with 21 additions and 5 deletions

View File

@@ -27,7 +27,12 @@ func (e *exporter) prepare() error {
}
ec := make(chan error, 1)
go func(fd uintptr) { ec <- exportFilter(fd, e.opts); close(ec); _ = e.closeWrite() }(e.w.Fd())
go func(fd uintptr) {
ec <- exportFilter(fd, e.opts)
close(ec)
_ = e.closeWrite()
runtime.KeepAlive(e.w)
}(e.w.Fd())
e.exportErr = ec
runtime.SetFinalizer(e, (*exporter).closeWrite)
})