If you want gdb to be able to attach to the running process, you need to run:

$ echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope

Next - Previous