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] Add pgrp() context tapset function. Describe sid().


* tapset/context.stp: Add pgrp() function.
* testsuite/buildok/context_test.stp: Add pgrp() call.
* stapfuncs.3stap.in: Describe pgrp() and sid().
---
 stapfuncs.3stap.in                 |    6 ++++++
 tapset/context.stp                 |   13 +++++++++++++
 testsuite/buildok/context_test.stp |    1 +
 3 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/stapfuncs.3stap.in b/stapfuncs.3stap.in
index b9326fd..518ff2b 100644
--- a/stapfuncs.3stap.in
+++ b/stapfuncs.3stap.in
@@ -210,6 +210,12 @@ Return the id of the current process.
 ppid:long ()
 Return the id of the parent process.
 .TP
+pgrp:long ()
+Return the pgrp of the current process.
+.TP
+sid:long ()
+Return the sid of the current process.
+.TP
 uid:long ()
 Return the uid of the current process.
 .TP
diff --git a/tapset/context.stp b/tapset/context.stp
index 468421a..5be9f21 100644
--- a/tapset/context.stp
+++ b/tapset/context.stp
@@ -64,6 +64,19 @@ function ppid:long () %{ /* pure */
 %}
 
 /**
+ * sfunction pgrp - Returns the process group ID of the current process.
+ */
+function pgrp:long () %{ /* pure */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
+	struct signal_struct *ss = kread( &(current->signal) );
+	THIS->__retvalue = kread ( &(ss->pgrp) );
+	CATCH_DEREF_FAULT();
+#else
+	THIS->__retvalue = task_pgrp_nr_ns(current, &init_pid_ns);
+#endif
+%}
+
+/**
  * sfunction sid - Returns the session ID of the current process.
  * 
  * The session ID of a process is the process group ID of the session
diff --git a/testsuite/buildok/context_test.stp b/testsuite/buildok/context_test.stp
index acc4ea0..e58c899 100755
--- a/testsuite/buildok/context_test.stp
+++ b/testsuite/buildok/context_test.stp
@@ -18,5 +18,6 @@ probe begin {
 	printf("gid is %d\n", gid())
 	printf("egid is %d\n", egid())
 	printf("pp is %s\n", pp())
+	printf("pgrp is %d\n", pgrp())
 	printf("sid is %d\n", sid())
 }
-- 
1.5.6.5


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