Skip to content

Commit

Permalink
pkg/domain: Make checkExecPreserveFDs platform-specific
Browse files Browse the repository at this point in the history
Also add a FreeBSD version.

[NO NEW TESTS NEEDED]

Signed-off-by: Doug Rabson <[email protected]>
  • Loading branch information
dfr committed Nov 15, 2022
1 parent f36b3bc commit 4c1294c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/domain/infra/abi/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/domain/infra/abi/containers_freebsd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package abi

const processFileDescriptorsPath = "/dev/fd"
3 changes: 3 additions & 0 deletions pkg/domain/infra/abi/containers_linux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package abi

const processFileDescriptorsPath = "/proc/self/fd"

0 comments on commit 4c1294c

Please sign in to comment.