commit | f7ee69f31298ecbe5d2b349c711e2547a617d398 | [log] [tgz] |
---|---|---|
author | Jonathan Boulle <jonathanboulle@gmail.com> | Wed Oct 07 16:04:24 2015 -0700 |
committer | Jonathan Boulle <jonathanboulle@gmail.com> | Wed Oct 07 16:04:24 2015 -0700 |
tree | dd4857964eba2290ef88a1639c136ebc621750e3 | |
parent | 5cf931ef8f76dccd0910001d74a58a7fca84a83d [diff] |
run: don't override supplied SysProcAttr If we're passed an exec.Cmd that already has a configured SysProcAttr, Start was obliterating it by overwriting it with a new struct in order to set `Setctty` and `Setsid`. Instead, just adjust the parameters that we need.
Pty is a Go package for using unix pseudo-terminals.
go get github.com/kr/pty
package main import ( "github.com/kr/pty" "io" "os" "os/exec" ) func main() { c := exec.Command("grep", "--color=auto", "bar") f, err := pty.Start(c) if err != nil { panic(err) } go func() { f.Write([]byte("foo\n")) f.Write([]byte("bar\n")) f.Write([]byte("baz\n")) f.Write([]byte{4}) // EOT }() io.Copy(os.Stdout, f) }