Skip to content

Commit fddd22b

Browse files
committed
Dup2 not supported on arm64 - use x/sys/unix for compat
1 parent af92418 commit fddd22b

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

logging/logging.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
"strings"
1010
"sync"
1111
"syscall"
12+
13+
"golang.org/x/sys/unix"
1214
)
1315

1416
// logWriter is a thread-safe writer that only writes to the central log buffer.
@@ -61,10 +63,10 @@ func InitialSetup() error {
6163
return fmt.Errorf("failed to create pipe: %w", err)
6264
}
6365

64-
if err := syscall.Dup2(int(w.Fd()), int(os.Stdout.Fd())); err != nil {
66+
if err := unix.Dup2(int(w.Fd()), int(os.Stdout.Fd())); err != nil {
6567
return fmt.Errorf("failed to redirect stdout: %w", err)
6668
}
67-
if err := syscall.Dup2(int(w.Fd()), int(os.Stderr.Fd())); err != nil {
69+
if err := unix.Dup2(int(w.Fd()), int(os.Stderr.Fd())); err != nil {
6870
return fmt.Errorf("failed to redirect stderr: %w", err)
6971
}
7072

@@ -186,12 +188,12 @@ func Close() error {
186188

187189
// Restore stdio first, so the final flush goes to the console.
188190
if originalStdout != -1 {
189-
syscall.Dup2(originalStdout, int(os.Stdout.Fd()))
191+
unix.Dup2(originalStdout, int(os.Stdout.Fd()))
190192
syscall.Close(originalStdout)
191193
originalStdout = -1
192194
}
193195
if originalStderr != -1 {
194-
syscall.Dup2(originalStderr, int(os.Stderr.Fd()))
196+
unix.Dup2(originalStderr, int(os.Stderr.Fd()))
195197
syscall.Close(originalStderr)
196198
originalStderr = -1
197199
}

0 commit comments

Comments
 (0)