[PATCH 4/4] Use printpid for printing pid of pidfd

Masatake YAMATO yamato at redhat.com
Fri Sep 3 20:28:43 UTC 2021


* src/util.c (printpidfd): Use printfd instead of
PRINT_VAL_D.

* src/pidns.c (printfd): Allow to pass NULL
as tcb when PID translation is not needed.

Suggested-by: Ákos Uzonyi <uzonyi.akos at gmail.com>
Signed-off-by: Masatake YAMATO <yamato at redhat.com>
---
 src/pidns.c | 3 ++-
 src/util.c  | 4 +++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/pidns.c b/src/pidns.c
index 9c7b7ce1a..59703d8c4 100644
--- a/src/pidns.c
+++ b/src/pidns.c
@@ -539,7 +539,8 @@ void
 printpid(struct tcb *tcp, int pid, enum pid_type type)
 {
 	PRINT_VAL_D(pid);
-	printpid_translation(tcp, pid, type);
+	if (tcp)
+	  printpid_translation(tcp, pid, type);
 }
 
 void
diff --git a/src/util.c b/src/util.c
index c944b3816..f9017b165 100644
--- a/src/util.c
+++ b/src/util.c
@@ -641,7 +641,9 @@ printpidfd(pid_t pid_of_fd, int fd, const char *path)
 		return false;
 
 	tprints("pid:");
-	PRINT_VAL_D(pid);
+	/* The pid translation is not needed because
+	 * the pid is in strace's namespace. */
+	printpid(NULL, pid, PT_TID);
 	return true;
 }
 
-- 
2.31.1



More information about the Strace-devel mailing list