|
|
|
|
@ -25,6 +25,7 @@ import (
|
|
|
|
|
"github.com/mitchellh/cli"
|
|
|
|
|
"github.com/mitchellh/panicwrap"
|
|
|
|
|
"github.com/mitchellh/prefixedio"
|
|
|
|
|
"github.com/shirou/gopsutil/process"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
@ -192,7 +193,12 @@ func wrappedMain() int {
|
|
|
|
|
}
|
|
|
|
|
ui = basicUi
|
|
|
|
|
if !inPlugin {
|
|
|
|
|
if TTY, err := openTTY(); err != nil {
|
|
|
|
|
currentPID := os.Getpid()
|
|
|
|
|
myProc, _ := process.NewProcess(int32(currentPID))
|
|
|
|
|
bg, _ := myProc.Background()
|
|
|
|
|
if bg {
|
|
|
|
|
fmt.Fprint(os.Stderr, "Running in background, not using a TTY\n")
|
|
|
|
|
} else if TTY, err := openTTY(); err != nil {
|
|
|
|
|
fmt.Fprintf(os.Stderr, "No tty available: %s\n", err)
|
|
|
|
|
} else {
|
|
|
|
|
basicUi.TTY = TTY
|
|
|
|
|
|