When using gdb to attach to the process. It shows

Could not attach to process. If your uid matches the uid of the target process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try again as the root user. For more details, see /etc/sysctl.d/10-ptrace.conf
ptrace: Operation not permitted.

As root I use echo 0 >/proc/sys/kernel/yama/ptrace_scope; then it shows:

bash: /proc/sys/kernel/yama/ptrace_scope: Read-only file system

How can I fix this problem? The content of /etc/sysctl.d/10-ptrace.conf is kernel.yama.ptrace_scope = 0

  • Can you try attaching that process with sudo?. And for the Read-only system you just remount your rootfs using sudo mount -o remount,rw / and then try. – Thushi Aug 7 '15 at 8:39
  • What kind of installation are you working on? Is this some kind of virtualized environment? – Gilles 'SO- stop being evil' Aug 7 '15 at 22:30

In docker you can now use the --privileged option, see https://docs.docker.com/engine/reference/commandline/exec/

docker exec --privileged -ti <container> bash

In privileged mode, gdb just works without any modifications to ptrace_scope.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.