github.com/markusbkk/elvish@v0.0.0-20231204143114-91dc52438621/pkg/eval/process_unix.go (about) 1 //go:build !windows && !plan9 2 // +build !windows,!plan9 3 4 package eval 5 6 import ( 7 "os" 8 "os/signal" 9 "syscall" 10 11 "github.com/markusbkk/elvish/pkg/sys" 12 "github.com/markusbkk/elvish/pkg/sys/eunix" 13 ) 14 15 // Process control functions in Unix. 16 17 func putSelfInFg() error { 18 if !sys.IsATTY(os.Stdin) { 19 return nil 20 } 21 // If Elvish is in the background, the tcsetpgrp call below will either fail 22 // (if the process is in an orphaned process group) or stop the process. 23 // Ignoring TTOU fixes that. 24 signal.Ignore(syscall.SIGTTOU) 25 defer signal.Reset(syscall.SIGTTOU) 26 return eunix.Tcsetpgrp(0, syscall.Getpgrp()) 27 } 28 29 func makeSysProcAttr(bg bool) *syscall.SysProcAttr { 30 return &syscall.SysProcAttr{Setpgid: bg} 31 }