about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2021-06-15 12:08:01 +0000
committerLeah Neukirchen <leah@vuxu.org>2021-06-15 14:50:59 +0200
commitc0e8a5424dfc2383eb2c996bd3e565c4aa3d59da (patch)
treee7daa9fd749006434e5d8e95280f920c5f3e9823
parentc2add535a901127a205ca003c90e9e8599c07365 (diff)
downloadextrace-c0e8a5424dfc2383eb2c996bd3e565c4aa3d59da.tar.gz
extrace-c0e8a5424dfc2383eb2c996bd3e565c4aa3d59da.tar.xz
extrace-c0e8a5424dfc2383eb2c996bd3e565c4aa3d59da.zip
extrace: skip parent lookup for pid 1
I was getting a lot of errors that looked like

    extrace: process vanished before we found its parent: pid 1: redirfd

Which are easily avoidable.
Message-Id: <20210615120801.121874-1-hi@alyssa.is>
-rw-r--r--extrace.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/extrace.c b/extrace.c
index e3a441a..4848a6f 100644
--- a/extrace.c
+++ b/extrace.c
@@ -140,6 +140,9 @@ pid_depth(pid_t pid)
 	char *s;
 	int fd, d, i;
 
+	if (pid == 1)
+		return 0;
+
 	snprintf(name, sizeof name, "/proc/%d/stat", pid);
 
 	if ((fd = open(name, O_RDONLY)) < 0)