diff options
-rw-r--r-- | extrace.c | 20 |
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; |