th32SnapEnumProcesses in System.Win32.Process prints debugging information to stdout
|Reported by:||guest||Owned by:||igloo|
|Type of failure:||Difficulty:||Unknown|
|Test Case:||Blocked By:|
Description (last modified by igloo)
TSIA, pretty much. I suspect that when the author was developing this function he put in some putStrLn calls for his own use and simply forgot to remove them. For my application I just took the code out of the library and ripped out the offending statements, but I don't think they're really supposed to be there and ought to be either removed or #ifdef'd out somehow. Here's my cleaned up version (I also removed some extraneous parenthesis, FWIW).
th32SnapEnumProcesses :: Th32SnapHandle -> IO [ProcessEntry32] th32SnapEnumProcesses h = allocaBytes 556 $ \pe -> do pokeByteOff pe 0 (556 :: DWORD) ok <- c_Process32First h pe readAndNext ok pe  where errStr = "th32SnapEnumProcesses: Process32First/Process32Next" readAndNext ok pe res | not ok = do err <- getLastError if err == 18 then return $ reverse res else failWith errStr err | otherwise = do entry <- peekProcessEntry32 pe ok' <- c_Process32Next h pe readAndNext ok' pe (entry:res)