Only make new process a group leader, not session
We're not dealing with a debugged process having its own controlling terminal at this point, so no need to make the new process a session leader. Simply making the process a group leader will suffice for our purposes at the moment.
This commit is contained in:
parent
77d46a51fb
commit
12bd0472d2
@ -37,14 +37,10 @@ fork_exec(char *argv0, char **argv, int size,
|
|||||||
read(fd[0], &sig, 1);
|
read(fd[0], &sig, 1);
|
||||||
close(fd[0]);
|
close(fd[0]);
|
||||||
|
|
||||||
// Create a new session for this process.
|
// Create a new process group.
|
||||||
if (setsid() < 0) {
|
|
||||||
// Could not set session, but still want to create
|
|
||||||
// a new process group.
|
|
||||||
if (setpgid(0, 0) < 0) {
|
if (setpgid(0, 0) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Set errno to zero before a call to ptrace.
|
// Set errno to zero before a call to ptrace.
|
||||||
// It is documented that ptrace can return -1 even
|
// It is documented that ptrace can return -1 even
|
||||||
|
@ -44,7 +44,7 @@ func Launch(cmd []string) (*Process, error) {
|
|||||||
proc.Args = cmd
|
proc.Args = cmd
|
||||||
proc.Stdout = os.Stdout
|
proc.Stdout = os.Stdout
|
||||||
proc.Stderr = os.Stderr
|
proc.Stderr = os.Stderr
|
||||||
proc.SysProcAttr = &syscall.SysProcAttr{Ptrace: true, Setsid: true}
|
proc.SysProcAttr = &syscall.SysProcAttr{Ptrace: true, Setpgid: true}
|
||||||
err = proc.Start()
|
err = proc.Start()
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user