github.com/dorkamotorka/go/src@v0.0.0-20230614113921-187095f0e316/syscall/forkpipe.go (about)

     1  // Copyright 2011 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  //go:build aix || darwin
     6  
     7  package syscall
     8  
     9  // Try to open a pipe with O_CLOEXEC set on both file descriptors.
    10  func forkExecPipe(p []int) error {
    11  	err := Pipe(p)
    12  	if err != nil {
    13  		return err
    14  	}
    15  	_, err = fcntl(p[0], F_SETFD, FD_CLOEXEC)
    16  	if err != nil {
    17  		return err
    18  	}
    19  	_, err = fcntl(p[1], F_SETFD, FD_CLOEXEC)
    20  	return err
    21  }