From 7c79f344d21bc19756d20201f0d72bb9b405c0fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caner=20=C3=87=C4=B1dam?= Date: Wed, 22 Apr 2026 20:24:32 +0200 Subject: [PATCH] fix Dup2 usage --- go.mod | 2 +- utils/detached.go | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index b1686744..d451036a 100644 --- a/go.mod +++ b/go.mod @@ -25,6 +25,7 @@ require ( github.com/stretchr/testify v1.10.0 github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4 v1.1.3 golang.org/x/sync v0.18.0 + golang.org/x/sys v0.38.0 gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.1 ) @@ -167,7 +168,6 @@ require ( golang.org/x/crypto v0.44.0 // indirect golang.org/x/net v0.47.0 // indirect golang.org/x/oauth2 v0.26.0 // indirect - golang.org/x/sys v0.38.0 // indirect golang.org/x/term v0.37.0 // indirect golang.org/x/text v0.31.0 // indirect golang.org/x/time v0.9.0 // indirect diff --git a/utils/detached.go b/utils/detached.go index 3675368f..6ab51341 100644 --- a/utils/detached.go +++ b/utils/detached.go @@ -9,6 +9,8 @@ import ( "strings" "sync" "syscall" + + "golang.org/x/sys/unix" ) // ReadyMarker is the line a re-exec'd child writes to its notify fd to tell @@ -198,14 +200,14 @@ func RedirectStdio(logPath string) error { } defer out.Close() - if err := syscall.Dup2(int(out.Fd()), int(os.Stdout.Fd())); err != nil { + if err := unix.Dup2(int(out.Fd()), int(os.Stdout.Fd())); err != nil { return fmt.Errorf("detach: redirect stdout: %w", err) } - if err := syscall.Dup2(int(out.Fd()), int(os.Stderr.Fd())); err != nil { + if err := unix.Dup2(int(out.Fd()), int(os.Stderr.Fd())); err != nil { return fmt.Errorf("detach: redirect stderr: %w", err) } if devNull, err := os.OpenFile(os.DevNull, os.O_RDONLY, 0); err == nil { - _ = syscall.Dup2(int(devNull.Fd()), int(os.Stdin.Fd())) + _ = unix.Dup2(int(devNull.Fd()), int(os.Stdin.Fd())) devNull.Close() } return nil