Set exit status to 1 if strace has not traced any processes

* strace.c (main): Initialize exit_code with 1 when no processes
has been attached.
* strace.1: Document it.
* NEWS: Mention this change.
This commit is contained in:
Дмитрий Левин 2016-07-29 17:51:54 +00:00
parent 2ddb73ddd3
commit b9bc216fdd
3 changed files with 12 additions and 3 deletions

4
NEWS
View File

@ -1,6 +1,10 @@
Noteworthy changes in release ?.?? (????-??-??)
===============================================
* Changes in behavior
* When using -p option without a command and no processes has been attached,
strace exits with exit status 1.
Noteworthy changes in release 4.13 (2016-07-26)
===============================================

View File

@ -601,10 +601,13 @@ unless
is used.
.LP
When using
.BR \-p ,
.B \-p
without a
.IR command ,
the exit status of
.B strace
is zero unless there was an unexpected error in doing the tracing.
is zero unless no processes has been attached or there was an unexpected error
in doing the tracing.
.SH "SETUID INSTALLATION"
If
.B strace

View File

@ -138,7 +138,7 @@ static bool skip_one_b_execve = 0;
/* Are we "strace PROG" and need to hide everything until execve? */
bool hide_log_until_execve = 0;
static int exit_code = 0;
static int exit_code;
static int strace_child = 0;
static int strace_tracer_pid = 0;
@ -2387,6 +2387,8 @@ main(int argc, char *argv[])
{
init(argc, argv);
exit_code = !nprocs;
while (trace())
;