pkg/domain: Make checkExecPreserveFDs platform-specific

Also add a FreeBSD version.

[NO NEW TESTS NEEDED]

Signed-off-by: Doug Rabson <dfr@rabson.org>
This commit is contained in:
Doug Rabson 2022-11-13 13:27:08 +00:00
parent f36b3bc811
commit 4c1294ccb7
3 changed files with 8 additions and 2 deletions

View File

@ -870,7 +870,7 @@ func makeExecConfig(options entities.ExecOptions, rt *libpod.Runtime) (*libpod.E
func checkExecPreserveFDs(options entities.ExecOptions) error {
if options.PreserveFDs > 0 {
entries, err := os.ReadDir("/proc/self/fd")
entries, err := os.ReadDir(processFileDescriptorsPath)
if err != nil {
return err
}
@ -879,7 +879,7 @@ func checkExecPreserveFDs(options entities.ExecOptions) error {
for _, e := range entries {
i, err := strconv.Atoi(e.Name())
if err != nil {
return fmt.Errorf("cannot parse %s in /proc/self/fd: %w", e.Name(), err)
return fmt.Errorf("cannot parse %s in %s: %w", e.Name(), processFileDescriptorsPath, err)
}
m[i] = true
}

View File

@ -0,0 +1,3 @@
package abi
const processFileDescriptorsPath = "/dev/fd"

View File

@ -0,0 +1,3 @@
package abi
const processFileDescriptorsPath = "/proc/self/fd"