summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2015-09-01 12:25:40 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-09-01 12:26:24 -0300
commit9840993b844b7f63f54a91e14c51d8ae2ba26c90 (patch)
tree1fc865a689cef471e879711fbd805c70b2996fac
parent487c7d8aaf463efa6561ec0ca8a5f25cb668c7c9 (diff)
downloadpython-linux-procfs-9840993b844b7f63f54a91e14c51d8ae2ba26c90.tar.gz
smaps: Provide usage example in the class documentation
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rwxr-xr-xprocfs/procfs.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/procfs/procfs.py b/procfs/procfs.py
index 21d2143..6b83151 100755
--- a/procfs/procfs.py
+++ b/procfs/procfs.py
@@ -752,6 +752,25 @@ class smaps:
List of libraries mapped by a process. Parses the lines in
the /proc/PID/smaps file, that is further documented in the
procfs(5) man page.
+
+ Example: Listing the executable maps for the 'sshd' process:
+
+ >>> import procfs
+ >>> processes = procfs.pidstats()
+ >>> sshd = processes.find_by_name("sshd")
+ >>> sshd_maps = procfs.smaps(sshd[0])
+ >>> for i in range(len(sshd_maps)):
+ ... if 'x' in sshd_maps[i].perms:
+ ... print "%s: %s" % (sshd_maps[i].name, sshd_maps[i].perms)
+ ...
+ /usr/sbin/sshd: r-xp
+ /usr/lib64/libnss_files-2.20.so: r-xp
+ /usr/lib64/librt-2.20.so: r-xp
+ /usr/lib64/libkeyutils.so.1.5: r-xp
+ /usr/lib64/libkrb5support.so.0.1: r-xp
+ /usr/lib64/libfreebl3.so: r-xp
+ /usr/lib64/libpthread-2.20.so: r-xp
+ ...
"""
def __init__(self, pid):
self.pid = pid