about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2022-01-02 19:28:06 +0100
committerLeah Neukirchen <leah@vuxu.org>2022-01-02 19:28:18 +0100
commit06a771fcfb511d2fab024d5970c9f4495abab8c3 (patch)
tree67569b31a4e2cec3956a8fd9c2872de9679e90f1
parent4253b9058b6961057dd9c5340f4a185b3730cd9b (diff)
downloadextrace-06a771fcfb511d2fab024d5970c9f4495abab8c3.tar.gz
extrace-06a771fcfb511d2fab024d5970c9f4495abab8c3.tar.xz
extrace-06a771fcfb511d2fab024d5970c9f4495abab8c3.zip
fix -p flag
Regression from c0e8a5424d, also fix error reporting of processes
we don't care about.
-rw-r--r--extrace.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/extrace.c b/extrace.c
index 4848a6f..9f5f166 100644
--- a/extrace.c
+++ b/extrace.c
@@ -140,7 +140,7 @@ pid_depth(pid_t pid)
 	char *s;
 	int fd, d, i;
 
-	if (pid == 1)
+	if (pid == 1 && parent == 1)
 		return 0;
 
 	snprintf(name, sizeof name, "/proc/%d/stat", pid);
@@ -345,14 +345,16 @@ handle_msg(struct cn_msg *cn_hdr)
 
 		d = pid_depth(pid);
 		if (d < 0) {
-			if (*cmdline) {
-				print_runtime_error(
-				    "extrace: process vanished before we found its parent: pid %d: %s\n",
-				    pid, cmdline);
-			} else {
-				print_runtime_error(
-				    "extrace: process vanished without a name: pid %d\n",
-				    pid);
+			if (parent == 1) {
+				if (*cmdline) {
+					print_runtime_error(
+					    "extrace: process vanished before we found its parent: pid %d: %s\n",
+					    pid, cmdline);
+				} else {
+					print_runtime_error(
+					    "extrace: process vanished without a name: pid %d\n",
+					    pid);
+				}
 			}
 			close(proc_dir_fd);
 			return;