From: Malte Nuhn <nuhn@physik.rwth-aachen.de>
To: systemtap@sources.redhat.com
Subject: context.stp - read session ID - function sid()
Date: Fri, 08 May 2009 15:04:00 -0000 [thread overview]
Message-ID: <4A044A00.8000600@physik.rwth-aachen.de> (raw)
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 */
next reply other threads:[~2009-05-08 15:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-08 15:04 Malte Nuhn [this message]
2009-05-08 20:06 ` Josh Stone
2009-05-11 12:21 ` Malte Nuhn
2009-05-11 18:22 ` Josh Stone
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A044A00.8000600@physik.rwth-aachen.de \
--to=nuhn@physik.rwth-aachen.de \
--cc=systemtap@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).