#2199: th32SnapEnumProcesses in System.Win32.Process prints debugging
information
to stdout
-----------------------------------+----------------------------------------
Reporter: guest | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 6.8.2
Severity: normal | Resolution:
Keywords: th32SnapEnumProcesses | Difficulty: Unknown
Testcase: | Architecture: Unknown
Os: Windows |
-----------------------------------+----------------------------------------
Changes (by igloo):
* difficulty: => Unknown
Old description:
> 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)
New description:
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)
}}}
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2199#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs