]> Cypherpunks repositories - gostls13.git/commitdiff
os, syscall: remove fallback to pipe syscall on Linux
authorTobias Klauser <tklauser@distanz.ch>
Wed, 1 Sep 2021 12:57:18 +0000 (14:57 +0200)
committerTobias Klauser <tobias.klauser@gmail.com>
Thu, 2 Sep 2021 09:24:44 +0000 (09:24 +0000)
The minimum required Linux kernel version for Go 1.18 will be changed to
2.6.32, see #45964. The pipe2 syscall was added in 2.6.27, so the
fallback to use the pipe syscall in os.Pipe and syscall.forkExecPipe on
Linux can be removed.

For #45964

Change-Id: I033a534f2b39e9bafc9980c9ce980e92f1e3a136
Reviewed-on: https://go-review.googlesource.com/c/go/+/346789
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/os/pipe_linux.go
src/syscall/exec_linux.go

index acd7b88e1d45d70d5f29e197699d72ddfc74e081..52f4e21e7c6616e95ccacfa72b8d52efcf91e945 100644 (file)
@@ -12,20 +12,7 @@ func Pipe() (r *File, w *File, err error) {
        var p [2]int
 
        e := syscall.Pipe2(p[0:], syscall.O_CLOEXEC)
-       // pipe2 was added in 2.6.27 and our minimum requirement is 2.6.23, so it
-       // might not be implemented.
-       if e == syscall.ENOSYS {
-               // See ../syscall/exec.go for description of lock.
-               syscall.ForkLock.RLock()
-               e = syscall.Pipe(p[0:])
-               if e != nil {
-                       syscall.ForkLock.RUnlock()
-                       return nil, nil, NewSyscallError("pipe", e)
-               }
-               syscall.CloseOnExec(p[0])
-               syscall.CloseOnExec(p[1])
-               syscall.ForkLock.RUnlock()
-       } else if e != nil {
+       if e != nil {
                return nil, nil, NewSyscallError("pipe2", e)
        }
 
index ccc0e39e30bda23cb5f7093b750c6562af14bc40..68bce7559b929c125d01c00ae9951006fbd47f16 100644 (file)
@@ -553,19 +553,7 @@ childerror:
 
 // Try to open a pipe with O_CLOEXEC set on both file descriptors.
 func forkExecPipe(p []int) (err error) {
-       err = Pipe2(p, O_CLOEXEC)
-       // pipe2 was added in 2.6.27 and our minimum requirement is 2.6.23, so it
-       // might not be implemented.
-       if err == ENOSYS {
-               if err = Pipe(p); err != nil {
-                       return
-               }
-               if _, err = fcntl(p[0], F_SETFD, FD_CLOEXEC); err != nil {
-                       return
-               }
-               _, err = fcntl(p[1], F_SETFD, FD_CLOEXEC)
-       }
-       return
+       return Pipe2(p, O_CLOEXEC)
 }
 
 func formatIDMappings(idMap []SysProcIDMap) []byte {