diff options
Diffstat (limited to 'llgo/third_party/gofrontend/libgo/go/syscall/exec_bsd.go')
| -rw-r--r-- | llgo/third_party/gofrontend/libgo/go/syscall/exec_bsd.go | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/llgo/third_party/gofrontend/libgo/go/syscall/exec_bsd.go b/llgo/third_party/gofrontend/libgo/go/syscall/exec_bsd.go index 217e0c842df..9042ce263aa 100644 --- a/llgo/third_party/gofrontend/libgo/go/syscall/exec_bsd.go +++ b/llgo/third_party/gofrontend/libgo/go/syscall/exec_bsd.go @@ -15,9 +15,12 @@ type SysProcAttr struct { Credential *Credential // Credential. Ptrace bool // Enable tracing. Setsid bool // Create session. - Setpgid bool // Set process group ID to new pid (SYSV setpgrp) - Setctty bool // Set controlling terminal to fd 0 + Setpgid bool // Set process group ID to Pgid, or, if Pgid == 0, to new pid. + Setctty bool // Set controlling terminal to fd Ctty Noctty bool // Detach fd 0 from controlling terminal + Ctty int // Controlling TTY fd + Foreground bool // Place child's process group in foreground. (Implies Setpgid. Uses Ctty as fd of controlling TTY) + Pgid int // Child's process group ID if Setpgid. } // Implemented in runtime package. @@ -90,8 +93,22 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr } // Set process group - if sys.Setpgid { - err1 = raw_setpgid(0, 0) + if sys.Setpgid || sys.Foreground { + // Place child in process group. + err1 = raw_setpgid(0, sys.Pgid) + if err1 != 0 { + goto childerror + } + } + + if sys.Foreground { + pgrp := Pid_t(sys.Pgid) + if pgrp == 0 { + pgrp = raw_getpid() + } + + // Place process group in foreground. + _, err1 = raw_ioctl_ptr(sys.Ctty, TIOCSPGRP, unsafe.Pointer(&pgrp)) if err1 != 0 { goto childerror } @@ -215,9 +232,9 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr } } - // Make fd 0 the tty + // Set the controlling TTY to Ctty if sys.Setctty { - _, err1 = raw_ioctl(0, TIOCSCTTY, 0) + _, err1 = raw_ioctl(sys.Ctty, TIOCSCTTY, 0) if err1 != 0 { goto childerror } |

