mirror of
https://github.com/go-delve/delve.git
synced 2025-10-29 01:27:16 +08:00
Create new session/process grp for forked process
This commit is contained in:
@ -34,6 +34,15 @@ fork_exec(char *argv0, char **argv, int size,
|
||||
read(fd[0], &sig, 1);
|
||||
close(fd[0]);
|
||||
|
||||
// Create a new session for this process.
|
||||
if (setsid() < 0) {
|
||||
// Could not set session, but still want to create
|
||||
// a new process group.
|
||||
if (setpgid(0, 0) < 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// Set errno to zero before a call to ptrace.
|
||||
// It is documented that ptrace can return -1 even
|
||||
// for successful calls.
|
||||
|
||||
@ -98,7 +98,7 @@ func Attach(pid int) (*Process, error) {
|
||||
}
|
||||
|
||||
func (dbp *Process) Kill() (err error) {
|
||||
err = sys.Kill(dbp.Pid, sys.SIGKILL)
|
||||
err = sys.Kill(-dbp.Pid, sys.SIGKILL)
|
||||
if err != nil {
|
||||
return errors.New("could not deliver signal: " + err.Error())
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ func Launch(cmd []string) (*Process, error) {
|
||||
proc.Args = cmd
|
||||
proc.Stdout = os.Stdout
|
||||
proc.Stderr = os.Stderr
|
||||
proc.SysProcAttr = &syscall.SysProcAttr{Ptrace: true}
|
||||
proc.SysProcAttr = &syscall.SysProcAttr{Ptrace: true, Setsid: true}
|
||||
err = proc.Start()
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user