Permalink
Browse files

For some reason /proc cmdline returns \x00 instead of spaces for some…

… processes
  • Loading branch information...
1 parent a381989 commit c45097ac398bae4d0326dfd61257c12dbea81b87 @sebastien committed Mar 20, 2012
Showing with 6 additions and 3 deletions.
  1. +6 −3 Sources/daemonwatch.py
View
@@ -6,7 +6,7 @@
# License : Revised BSD Licensed
# -----------------------------------------------------------------------------
# Creation date : 10-Feb-2010
-# Last mod. : 27-Dec-2011
+# Last mod. : 20-Mar-2012
# -----------------------------------------------------------------------------
import re, sys, os, time, datetime, stat, smtplib, string, json, fnmatch
@@ -37,9 +37,12 @@
__version__ = "0.9.3"
-RE_SPACES = re.compile("\s+")
+RE_SPACES = re.compile("\s+")
RE_INTEGER = re.compile("\d+")
+def config(variable, default, normalize=lambda _:_):
+ return normalize(os.environ.get(variable.upper().replace(".","_")) or default)
+
def cat(path):
"""Outputs the content of the file at the given path"""
try:
@@ -268,7 +271,7 @@ def List(self):
for p in glob.glob("/proc/*/cmdline"):
process = p.split("/")[2]
if process != "self":
- res[int(process)] = cat(p)
+ res[int(process)] = cat(p).replace("\x00", " ")
return res
@classmethod

0 comments on commit c45097a

Please sign in to comment.