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 26, 2019
1 parent a73c607 commit 8e1aad4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion utils/ptrace.c
Expand Up @@ -14,8 +14,13 @@ 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"
"[example]\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 8e1aad4

Please sign in to comment.