From 9a9f660998857dba72a13a7376c32ae6c41c1a64 Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Mon, 30 Dec 2013 04:36:19 +0100 Subject: Fix for Top parsing of command lines containing blanks --- src/Plugins/Monitors/Top.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/Plugins') diff --git a/src/Plugins/Monitors/Top.hs b/src/Plugins/Monitors/Top.hs index 6f16bdb..6be3c1c 100644 --- a/src/Plugins/Monitors/Top.hs +++ b/src/Plugins/Monitors/Top.hs @@ -57,10 +57,15 @@ processes :: IO [FilePath] processes = fmap (filter isPid) (getDirectoryContents "/proc") where isPid = (`elem` ['0'..'9']) . head +statWords :: [String] -> [String] +statWords line@(x:pn:ppn:xs) = + if last pn == ')' then line else statWords (x:(pn ++ " " ++ ppn):xs) +statWords _ = replicate 52 "0" + getProcessData :: FilePath -> IO [String] getProcessData pidf = handle ign $ withFile ("/proc" pidf "stat") ReadMode readWords - where readWords = fmap words . hGetLine + where readWords = fmap (statWords . words) . hGetLine ign = const (return []) :: SomeException -> IO [String] handleProcesses :: ([String] -> a) -> IO [a] -- cgit v1.2.3