github.com/hashicorp/packer@v1.14.3/helper/wrappedstreams/streams_other.go (about)

     1  // Copyright (c) HashiCorp, Inc.
     2  // SPDX-License-Identifier: BUSL-1.1
     3  
     4  //go:build !windows
     5  // +build !windows
     6  
     7  package wrappedstreams
     8  
     9  import (
    10  	"os"
    11  	"sync"
    12  )
    13  
    14  var initOnce sync.Once
    15  
    16  func initPlatform() {
    17  	// These must be initialized lazily, once it's been determined that this is
    18  	// a wrapped process.
    19  	initOnce.Do(func() {
    20  		// The standard streams are passed in via extra file descriptors.
    21  		wrappedStdin = os.NewFile(uintptr(3), "stdin")
    22  		wrappedStdout = os.NewFile(uintptr(4), "stdout")
    23  		wrappedStderr = os.NewFile(uintptr(5), "stderr")
    24  	})
    25  }