development list for leahutils (lr, xe, snooze, ...)
 help / color / mirror / Atom feed
* [PATCH] extrace: skip parent lookup for pid 1
@ 2021-06-15 12:08 Alyssa Ross
  0 siblings, 0 replies; only message in thread
From: Alyssa Ross @ 2021-06-15 12:08 UTC (permalink / raw)
  To: leahutils; +Cc: Alyssa Ross

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.
---
 extrace.c | 3 +++
 1 file changed, 3 insertions(+)

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)
-- 
2.31.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-06-15 12:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-15 12:08 [PATCH] extrace: skip parent lookup for pid 1 Alyssa Ross

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).