Exit code is 0 when attaching to process fails

Oliver Hanappi oliver.hanappi at gmail.com
Mon May 4 09:41:44 UTC 2015


Hello!

strace requires that the ptrace_scope is set to 0 in order to be able to
attach to non child processes.
If attaching fails strace prints an error message, but the exit code is 0.
I expect a nonzero exit code.

The manual states the following:

> When using -p, the exit status of strace is zero unless there was an
unexpected error in doing the tracing.

The behavior is reproducable with strace 4.8 and 4.10.

An example:

$ strace -p 1234
strace: attach: ptrace(PTRACE_ATTACH, ...): Operation not permitted
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
$ echo $?
> 0

Regards,
Oliver Hanappi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20150504/973a54ed/attachment.html>


More information about the Strace-devel mailing list