mirror of https://github.com/Hilbis/Hilbish
29 lines
483 B
Go
29 lines
483 B
Go
|
// +build darwin linux
|
||
|
|
||
|
package main
|
||
|
|
||
|
import (
|
||
|
"errors"
|
||
|
"os"
|
||
|
"syscall"
|
||
|
|
||
|
"golang.org/x/sys/unix"
|
||
|
)
|
||
|
|
||
|
func (j *job) foreground() error {
|
||
|
if jobs.foreground {
|
||
|
return errors.New("(another) job already foregrounded")
|
||
|
}
|
||
|
|
||
|
pgid, _ := syscall.Getpgid(j.pid)
|
||
|
// tcsetpgrp
|
||
|
unix.IoctlSetPointerInt(0, unix.TIOCSPGRP, pgid)
|
||
|
proc, _ := os.FindProcess(j.pid)
|
||
|
proc.Wait()
|
||
|
|
||
|
hshPgid, _ := syscall.Getpgid(os.Getpid())
|
||
|
unix.IoctlSetPointerInt(0, unix.TIOCSPGRP, hshPgid)
|
||
|
|
||
|
return nil
|
||
|
}
|