summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@strace.io>2022-03-13 08:00:00 +0000
committerDmitry V. Levin <ldv@strace.io>2022-03-13 08:00:00 +0000
commit6545ce181ba5ccecec4853c5290c53d39946f99f (patch)
tree3ebda0ff0827fd043ef2511762055dfe4ea0c6f4
parent41b43180d9fddc1235b659689cf8f6764dd82ced (diff)
downloadstrace-6545ce181ba5ccecec4853c5290c53d39946f99f.tar.gz
printpidfd: print pidfd path if pidfd_get_pid fails
* src/util.c (printpidfd): If the path associated with the given descriptor is "anon_inode:[pidfd]", print the path if pidfd_get_pid fails.
-rw-r--r--src/util.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/util.c b/src/util.c
index 9f518be53..f055b44c5 100644
--- a/src/util.c
+++ b/src/util.c
@@ -711,16 +711,18 @@ printpidfd(pid_t pid_of_fd, int fd, const char *path)
return false;
pid_t pid = pidfd_get_pid(pid_of_fd, fd);
- if (pid <= 0)
- return false;
+ if (pid > 0) {
+ tprints("<pid:");
+ /*
+ * The pid translation is not needed because
+ * the pid is in strace's namespace.
+ */
+ printpid(NULL, pid, PT_TID);
+ tprints(">");
+ } else {
+ print_string_in_angle_brackets(path);
+ }
- tprints("<pid:");
- /*
- * The pid translation is not needed because
- * the pid is in strace's namespace.
- */
- printpid(NULL, pid, PT_TID);
- tprints(">");
return true;
}