All checks were successful
Test / Create distribution (push) Successful in 1m2s
Test / Sandbox (push) Successful in 2m44s
Test / Hakurei (push) Successful in 3m42s
Test / ShareFS (push) Successful in 3m46s
Test / Sandbox (race detector) (push) Successful in 5m1s
Test / Hakurei (race detector) (push) Successful in 6m7s
Test / Flake checks (push) Successful in 1m23s
This is guarded behind the close_range build tag for now. Signed-off-by: Ophestra <cat@gensokyo.uk>
29 lines
478 B
Go
29 lines
478 B
Go
//go:build !close_range
|
|
|
|
package container
|
|
|
|
import (
|
|
"os"
|
|
"strconv"
|
|
"syscall"
|
|
|
|
"hakurei.app/container/fhs"
|
|
)
|
|
|
|
// doCloseOnExec implements ensureCloseOnExec by ranging over proc_pid_fd(5).
|
|
func doCloseOnExec() error {
|
|
entries, err := os.ReadDir(fhs.ProcSelf + "fd/")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
var fd int
|
|
for _, ent := range entries {
|
|
if fd, err = strconv.Atoi(ent.Name()); err != nil {
|
|
return err // not reached
|
|
}
|
|
syscall.CloseOnExec(fd)
|
|
}
|
|
return nil
|
|
}
|