Skip to content

Commit

Permalink
utils: add warning message when ptrace_attach failed
Browse files Browse the repository at this point in the history
attaching to already running process require permission for use ptrace
functionality that supports by linux kernel. recently kernel disable
ptrace at default. so, user who want use attaching must enable ptrace.
added message guide user how to do this.

Signed-off-by: Hanbum Park <kese111@gmail.com>
  • Loading branch information
ParkHanbum committed Apr 13, 2019
1 parent 20eb05d commit 05cb96a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion utils/ptrace.c
Expand Up @@ -14,8 +14,12 @@ void ptrace_attach(pid_t target)
{
int status;

if (ptrace(PTRACE_ATTACH, target, NULL, NULL) == -1)
if (ptrace(PTRACE_ATTACH, target, NULL, NULL) == -1) {
pr_warn("attaching requires ptrace permission.\n"
"please, enable ptrace permission like following.\n"
"echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope\n");
pr_err("ptrace(PTRACE_ATTACH) failed");
}

if (waitpid(target, &status, WUNTRACED) != target)
pr_err("waitpid(%d) failed", target);
Expand Down

0 comments on commit 05cb96a

Please sign in to comment.