This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
context.stp - read session ID - function sid()
- From: Malte Nuhn <nuhn at physik dot rwth-aachen dot de>
- To: systemtap at sources dot redhat dot com
- Date: Fri, 08 May 2009 17:04:32 +0200
- Subject: context.stp - read session ID - function sid()
Hi there,
I coded some lines to read out the session ID of the current caller.
Eventhough this piece of information is always called "session" inside
the kernel,
it seems that the function name "sid()" is a good idea.
There's basically no magic in it. I checked that the session information
is stored in the
"signal_struct" since Kernel version 2.6.0 - so i guess it should work
on every
machine that is running systemtap.
The following patch should be applied to current file in git, which was
git log
commit 07f8225311f85de5754bb594bf6ee945425dafcc
...
Malte
diff --git a/tapset/context.stp b/tapset/context.stp
index fcb6020..a5a839a 100644
--- a/tapset/context.stp
+++ b/tapset/context.stp
@@ -64,6 +64,18 @@ function ppid:long () %{ /* pure */
%}
/**
+* sfunction sid - Returns the session ID of the current process.
+*
+* The session ID of a process is the process group ID of the session
leader.
+* Session ID is stored in the signal_struct since Kernel 2.6.0
+*/
+function sid:long () %{ /* pure */
+ struct signal_struct *ss = kread( &(current->signal) );
+ THIS->__retvalue = kread ( &(ss->session) );
+ CATCH_DEREF_FAULT();
+%}
+
+/**
* sfunction pexecname - Returns the execname of a target process's
parent process.
*/
function pexecname:string () %{ /* pure */