Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.

Commit 0e8afb8

Browse files
committed
linux: Convert dup2 calls to dup3
Convert syscall.Dup2 calls to syscall.Dup3. The dup2 syscall is depreciated and is not available on some architectures. Fixes build errors like these when building for arm64: console_linux.go: undefined: syscall.Dup2 Signed-off-by: Geoff Levand <[email protected]>
1 parent 4369703 commit 0e8afb8

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Diff for: console_linux.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func (c *linuxConsole) mount(rootfs, mountLabel string, uid, gid int) error {
9292
return syscall.Mount(c.slavePath, dest, "bind", syscall.MS_BIND, "")
9393
}
9494

95-
// dupStdio opens the slavePath for the console and dup2s the fds to the current
95+
// dupStdio opens the slavePath for the console and dups the fds to the current
9696
// processes stdio, fd 0,1,2.
9797
func (c *linuxConsole) dupStdio() error {
9898
slave, err := c.open(syscall.O_RDWR)
@@ -101,7 +101,7 @@ func (c *linuxConsole) dupStdio() error {
101101
}
102102
fd := int(slave.Fd())
103103
for _, i := range []int{0, 1, 2} {
104-
if err := syscall.Dup2(fd, i); err != nil {
104+
if err := syscall.Dup3(fd, i, 0); err != nil {
105105
return err
106106
}
107107
}

Diff for: rootfs_linux.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ func reOpenDevNull(rootfs string) error {
272272
}
273273
if stat.Rdev == devNullStat.Rdev {
274274
// Close and re-open the fd.
275-
if err := syscall.Dup2(int(file.Fd()), fd); err != nil {
275+
if err := syscall.Dup3(int(file.Fd()), fd, 0); err != nil {
276276
return err
277277
}
278278
}

0 commit comments

Comments
 (0)