title: Why does this exec.Command to a different opened tty not work properly
body: <p>Can anybody please help me figure out what I'm doing wrong here.</p>
  
  <p>I'm trying to execute a command (opening vim in this case) that runs in a different tty, in this case /dev/ttys001, which is opened in another tab in my terminal.</p>
  
  <p>Running the code below does render vim in /dev/ttys001's window, however, actually typing to stdin from that window doesn't register properly.</p>
  
  <p>Any advice is much appreciated!</p>
  
  <pre><code>package main
  
  import (
      "log"
      "os"
      "os/exec"
  )
  
  func main() {
      tty, err := os.OpenFile("/dev/ttys001", os.O_RDWR, os.ModePerm)
      if err != nil {
          log.Fatalln(err)
      }
      defer tty.Close()
  
      c := exec.Command("vim")
      c.Stdin = tty
      c.Stdout = tty
      c.Stderr = tty
      if err := c.Run(); err != nil {
          log.Fatalln(err)
      }
  }
  </code></pre>
  
  <p>I have also tried setting the command's SysProcAttr field with the following code but receive the error: fork/exec /usr/local/bin/vim: inappropriate ioctl for device.</p>
  
  <pre><code>procAttr := &amp;syscall.SysProcAttr{
      Setpgid:    true,
      Ctty:       int(tty.Fd()),
      Foreground: true,
  }
  c.SysProcAttr = procAttr
  </code></pre>