2 * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
13 #include "user_util.h"
14 #include "kern_util.h"
16 #include "ptrace_user.h"
19 void do_exec(int old_pid
, int new_pid
)
21 unsigned long regs
[FRAME_SIZE
];
24 if((ptrace(PTRACE_ATTACH
, new_pid
, 0, 0) < 0) ||
25 (ptrace(PTRACE_CONT
, new_pid
, 0, 0) < 0))
26 tracer_panic("do_exec failed to attach proc - errno = %d",
29 CATCH_EINTR(err
= waitpid(new_pid
, 0, WUNTRACED
));
31 tracer_panic("do_exec failed to attach proc in waitpid - errno = %d",
34 if(ptrace_getregs(old_pid
, regs
) < 0)
35 tracer_panic("do_exec failed to get registers - errno = %d",
38 os_kill_ptraced_process(old_pid
, 0);
40 if (ptrace(PTRACE_OLDSETOPTIONS
, new_pid
, 0, (void *)PTRACE_O_TRACESYSGOOD
) < 0)
41 tracer_panic("do_exec: PTRACE_SETOPTIONS failed, errno = %d", errno
);
43 if(ptrace_setregs(new_pid
, regs
) < 0)
44 tracer_panic("do_exec failed to start new proc - errno = %d",
49 * Overrides for Emacs so that we follow Linus's tabbing style.
50 * Emacs will notice this stuff at the end of the file and automatically
51 * adjust the settings for this buffer only. This must remain at the end
53 * ---------------------------------------------------------------------------
55 * c-file-style: "linux"