If you prefer to leave /proc/sys/kernel/yama/ptrace_scope
set to its default value of 1
, then as a workaround you could consider using gdb
to run the program you want to debug. You can then bring up the debugger simply by pressing ^C
. For example, to debug to the (boring) program sleep 60
, do the following:
$ gdb -q sleep -ex 'run 60'
Here is a complete example.
$ gdb -q sleep -ex 'run 60'
Reading symbols from sleep...(no debugging symbols found)...done.
Starting program: /bin/sleep 60
^C
Program received signal SIGINT, Interrupt.
0x00007ffff7ad5d60 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:81
81 ../sysdeps/unix/syscall-template.S: No such file or directory.
(gdb) backtrace
#0 0x00007ffff7ad5d60 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:81
#1 0x0000000000403cd7 in ?? ()
#2 0x0000000000403b88 in ?? ()
#3 0x00000000004016c9 in ?? ()
#4 0x00007ffff7a35ec5 in __libc_start_main (main=0x401540, argc=2, argv=0x7fffffffea08, init=<optimized out>,
fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffe9f8) at libc-start.c:287
#5 0x00000000004017d5 in ?? ()
(gdb) continue
Continuing.
[Inferior 1 (process 3531) exited normally]
(gdb) quit
Since /bin/sleep
was (unsurprisingly) compiled without debugging information, the above backtrace contains minimal information.
/etc/sysctl.d/10-ptrace.conf
file. it works perfectly for me. :) – soroosh Apr 20 '13 at 14:29/etc/sysctl.d
to become effective. For me, a system restart was sufficient, but may have been overkill -- see frankster's comment above. After the restart, the value from/etc/sysctl.d
is copied into/proc/sys/kernel/yama/ptrace_scope
. (Also, in my case I could not edit ptrace_scope directly, even with sudo.) – Andy Thomas Mar 26 '15 at 21:04sysctl -p
to apply changes from/etc/sysctl.conf
and/etc/sysctl.d/*
. For this specific change, in Ubuntu 15.04 Vivid , the file is/etc/sysctl.d/10-ptrace.conf
– Mircea Vutcovici Aug 11 '15 at 14:52