processinfo

This commit is contained in:
Megan Marsh 2019-06-03 14:13:36 -07:00
parent f2a517dfd7
commit 09f63cea0b
1 changed files with 7 additions and 1 deletions

View File

@ -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