github.com/mattn/go@v0.0.0-20171011075504-07f7db3ea99f/src/syscall/exec_freebsd.go (about)

     1  // Copyright 2017 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package syscall
     6  
     7  func forkExecPipe(p []int) error {
     8  	err := Pipe2(p, O_CLOEXEC)
     9  	if err == nil {
    10  		return nil
    11  	}
    12  
    13  	// FreeBSD 9 fallback.
    14  	// TODO: remove this for Go 1.10 per Issue 19072
    15  	err = Pipe(p)
    16  	if err != nil {
    17  		return err
    18  	}
    19  	_, err = fcntl(p[0], F_SETFD, FD_CLOEXEC)
    20  	if err != nil {
    21  		return err
    22  	}
    23  	_, err = fcntl(p[1], F_SETFD, FD_CLOEXEC)
    24  	return err
    25  }