[PATCH] Handle not being able to open /proc/<pid>/cmdline. Return "-" as netstat does when it doesn't know the command listening.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 func/minion/modules/portinfo.py |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/func/minion/modules/portinfo.py b/func/minion/modules/portinfo.py
index af94364..bfeb44b 100644
--- a/func/minion/modules/portinfo.py
+++ b/func/minion/modules/portinfo.py
@@ -14,7 +14,7 @@ import sub_process
 
 class PortinfoModule(func_module.FuncModule):
 
-    version = "0.0.2"
+    version = "0.0.3"
     api_version = "0.0.1"
     description = "Information on active network ports and processes listening."
 
@@ -57,5 +57,9 @@ class PortinfoModule(func_module.FuncModule):
         """
         Returns the commandline for a given pid as a string.
         """
-        proccmdline = open("/proc/" + pid + "/cmdline").readline().split('\x00')
-        return " ".join(proccmdline)
+        try:
+            proccmdline = open("/proc/" + pid + "/cmdline").readline().split('\x00')
+            return " ".join(proccmdline)
+        except Exception, e:
+            # If we can't find the cmdline, return "-" as netstat would.
+            return "-"
-- 
1.7.1

_______________________________________________
Func-list mailing list
Func-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/func-list


[Index of Archives]     [Fedora Users]     [Linux Networking]     [Fedora Legacy List]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux