This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] examples: Print PID of peer for unix sockets


This information is very useful for debugging but is not normally
available to userland since /proc/net/unix does not list it.
---
 testsuite/systemtap.examples/process/pfiles.stp |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/testsuite/systemtap.examples/process/pfiles.stp b/testsuite/systemtap.examples/process/pfiles.stp
index 796a4f0..095f1a7 100755
--- a/testsuite/systemtap.examples/process/pfiles.stp
+++ b/testsuite/systemtap.examples/process/pfiles.stp
@@ -620,6 +620,8 @@ function print_unix_socket(sock) {
 	peername = socket_unix_peername(sock)
 	printf("%s%s", strlen(sockname) > 0 ? sockname . "\n" : "",
 		strlen(peername) > 0 ? peername . "\n" : "")
+	printf("        peercred pid: %d\n",
+	    @cast(sock, "socket")->sk->sk_peercred->pid);
 }
 
 function print_ipv4_socket(sock) {
-- 
1.7.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]