// Starts a new process from the given information and begins tracing.
Starts a new process from the given information and begins tracing.
// Starts a new process from the given information and begins tracing .
func startProc(pie PieOffsetter, target string, args []string, regions []Region) (*Proc, error) {
	cmd := exec.Command(target, args...)
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	cmd.Stdin = os.Stdin
	cmd.SysProcAttr = &unix.SysProcAttr{
		Ptrace: true,
	}
	err := cmd.Start()
	if err != nil {
		return nil, err
	}
	cmd.Wait()
	options := unix.PTRACE_O_EXITKILL | unix.PTRACE_O_TRACECLONE |
		unix.PTRACE_O_TRACEFORK | unix.PTRACE_O_TRACEVFORK |
		unix.PTRACE_O_TRACEEXEC
	p, err := newTracedProc(cmd.Process.Pid, pie, regions, nil)
	if err != nil {
		return nil, err
	}
	err = p.tracer.ReAttachAndContinue(options)
	if err != nil {
		return nil, err
	}
	var ws unix.WaitStatus
	_, err = unix.Wait4(p.tracer.Pid(), &ws, 0, nil)
	if err != nil {
		return nil, err
	} else if ws.StopSignal() != unix.SIGTRAP {
		return nil, errors.New("wait: received non SIGTRAP: " + ws.StopSignal().String())
	}
	err = p.cont(0, false)
	return p, err
}
func startProc ( pie PieOffsetter , target string , args [ ] string , regions [ ] Region ) ( * Proc , error ) { cmd := exec . Command ( target , args ... ) cmd . Stdout = os . Stdout cmd . Stderr = os . Stderr cmd . Stdin = os . Stdin cmd . SysProcAttr = & unix . SysProcAttr { Ptrace : true , } err := cmd . Start ( ) if err != nil { return nil , err } cmd . Wait ( ) options := unix . PTRACE_O_EXITKILL | unix . PTRACE_O_TRACECLONE | unix . PTRACE_O_TRACEFORK | unix . PTRACE_O_TRACEVFORK | unix . PTRACE_O_TRACEEXEC p , err := newTracedProc ( cmd . Process . Pid , pie , regions , nil ) if err != nil { return nil , err } err = p . tracer . ReAttachAndContinue ( options ) if err != nil { return nil , err } var ws unix . WaitStatus _ , err = unix . Wait4 ( p . tracer . Pid ( ) , & ws , 0 , nil ) if err != nil { return nil , err } else if ws . StopSignal ( ) != unix . SIGTRAP { return nil , errors . New ( " " + ws . StopSignal ( ) . String ( ) ) } err = p . cont ( 0 , false ) return p , err }
Starts a new process from the given information and begins tracing.
Starts a new process from the given information and begins tracing .
// wait for execve // Wait for the initial SIGTRAP created because we are attaching // with ReAttachAndContinue to properly handle group stops.