From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27850 invoked by alias); 8 May 2009 15:04:47 -0000 Received: (qmail 27826 invoked by uid 22791); 8 May 2009 15:04:45 -0000 X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=BAYES_00,J_CHICKENPOX_34,J_CHICKENPOX_44 X-Spam-Check-By: sourceware.org Received: from mta-1.ms.rz.RWTH-Aachen.DE (HELO mta-1.ms.rz.rwth-aachen.de) (134.130.7.72) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 08 May 2009 15:04:35 +0000 MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; charset=ISO-8859-1; format=flowed Received: from ironport-out-1.rz.rwth-aachen.de ([134.130.5.40]) by mta-1.ms.rz.RWTH-Aachen.de (Sun Java(tm) System Messaging Server 6.3-7.04 (built Sep 26 2008)) with ESMTP id <0KJB00FTSZ7KHZA0@mta-1.ms.rz.RWTH-Aachen.de> for systemtap@sources.redhat.com; Fri, 08 May 2009 17:04:32 +0200 (CEST) Received: from relay-2.ms.rz.rwth-aachen.de (HELO relay.rwth-aachen.de) ([134.130.7.75]) by ironport-in-1.rz.rwth-aachen.de with ESMTP; Fri, 08 May 2009 17:04:32 +0200 Received: from [134.61.14.38] (lx3b07.physik.RWTH-Aachen.DE [134.61.14.38]) by relay.rwth-aachen.de (8.13.8+Sun/8.13.8/1) with ESMTP id n48F4W6N002471 for ; Fri, 08 May 2009 17:04:32 +0200 (CEST) Message-id: <4A044A00.8000600@physik.rwth-aachen.de> Date: Fri, 08 May 2009 15:04:00 -0000 From: Malte Nuhn User-Agent: Thunderbird 1.5.0.12 (X11/20090324) To: systemtap@sources.redhat.com Subject: context.stp - read session ID - function sid() X-IsSubscribed: yes Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org X-SW-Source: 2009-q2/txt/msg00516.txt.bz2 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 */