container/params: pass fd instead of file

The file is very difficult to stub. Pass fd instead as it is the value that is actually useful.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2025-08-23 00:16:46 +09:00
parent 1c692bfb79
commit ea1e3ebae9
5 changed files with 19 additions and 22 deletions

View File

@@ -25,7 +25,7 @@ func Setup(extraFiles *[]*os.File) (int, *gob.Encoder, error) {
}
// Receive retrieves setup fd from the environment and receives params.
func Receive(key string, e any, v **os.File) (func() error, error) {
func Receive(key string, e any, fdp *uintptr) (func() error, error) {
var setup *os.File
if s, ok := os.LookupEnv(key); !ok {
@@ -38,8 +38,8 @@ func Receive(key string, e any, v **os.File) (func() error, error) {
if setup == nil {
return nil, syscall.EBADF
}
if v != nil {
*v = setup
if fdp != nil {
*fdp = setup.Fd()
}
}
}