syscall: Add Foreground and Pgid to SysProcAttr

On Unix, when placing a child in a new process group, allow that group
to become the foreground process group. Also, allow a child process to
join a specific process group.

When setting the foreground process group, Ctty is used as the file
descriptor of the controlling terminal. Ctty has been added to the BSD
and Solaris SysProcAttr structures and the handling of Setctty changed
to match Linux.

Change-Id: I18d169a6c5ab8a6a90708c4ff52eb4aded50bc8c
Reviewed-on: https://go-review.googlesource.com/5130
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Michael MacInnis 2015-02-17 22:23:16 -05:00 committed by Ian Lance Taylor
parent 5bf9249eda
commit f7befa43a3
7 changed files with 317 additions and 17 deletions

View file

@ -16,6 +16,7 @@ var (
libc_fcntl,
libc_forkx,
libc_gethostname,
libc_getpid,
libc_ioctl,
libc_pipe,
libc_setgid,
@ -183,6 +184,17 @@ func syscall_gethostname() (name string, err uintptr) {
return gostringnocopy(&cname[0]), 0
}
//go:nosplit
func syscall_getpid() (pid, err uintptr) {
call := libcall{
fn: uintptr(unsafe.Pointer(libc_getpid)),
n: 0,
args: uintptr(unsafe.Pointer(libc_getpid)), // it's unused but must be non-nil, otherwise crashes
}
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
return call.r1, call.err
}
//go:nosplit
func syscall_ioctl(fd, req, arg uintptr) (err uintptr) {
call := libcall{