github.com/hazelops/ize@v1.1.12-0.20230915191306-97d7c0e48f11/pkg/term/interactive_windows.go (about)

     1  //go:build windows
     2  // +build windows
     3  
     4  package term
     5  
     6  import (
     7  	"os"
     8  	"os/exec"
     9  	"os/signal"
    10  )
    11  
    12  // InteractiveRun runs the input command that starts a child process.
    13  func (r Runner) InteractiveRun(cmd *exec.Cmd) (err error) {
    14  	sig := make(chan os.Signal, 1)
    15  	// See https://golang.org/pkg/os/signal/#hdr-Windows
    16  	signal.Notify(sig, os.Interrupt)
    17  	defer signal.Reset(os.Interrupt)
    18  
    19  	cmd.Dir = r.dir
    20  	if r.stdin != nil {
    21  		cmd.Stdin = r.stdin
    22  	}
    23  	cmd.Stdout = r.stdout
    24  	cmd.Stderr = r.stderr
    25  	return cmd.Run()
    26  }