]> granicus.if.org Git - strace/commitdiff
Set exit status to 1 if strace has not traced any processes
authorDmitry V. Levin <ldv@altlinux.org>
Fri, 29 Jul 2016 17:51:54 +0000 (17:51 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 29 Jul 2016 22:47:46 +0000 (22:47 +0000)
* strace.c (main): Initialize exit_code with 1 when no processes
has been attached.
* strace.1: Document it.
* NEWS: Mention this change.

NEWS
strace.1
strace.c

diff --git a/NEWS b/NEWS
index 19a870df6b0e8a14234ee9f12360b9a08d83f4d5..e1fb23ec3a809b98b2fbff6df6bb9088fe9f7ae4 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -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)
 ===============================================
 
index b7dddc0b3c56b823244727ced0d4e39dc51cf574..6cc17c5ccf851391e0f253eee10c7a3fa1500e47 100644 (file)
--- a/strace.1
+++ b/strace.1
@@ -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
index 2e2d4b5ec2a381597eee76cba91c67697ef0b1f4..680456bf92052a6f54b85be10234ef0e600eea22 100644 (file)
--- a/strace.c
+++ b/strace.c
@@ -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())
                ;