Ticket #2199 (closed merge: fixed)

Opened 5 years ago

Last modified 5 years ago

th32SnapEnumProcesses in System.Win32.Process prints debugging information to stdout

Reported by: guest Owned by: igloo
Priority: normal Milestone: 6.8.3
Component: Compiler Version: 6.8.2
Keywords: th32SnapEnumProcesses Cc:
Operating System: Windows Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description (last modified by igloo) (diff)

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)

Change History

Changed 5 years ago by guest

Sorry about that formatting, let me try again:

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)

Changed 5 years ago by igloo

  • difficulty set to Unknown
  • description modified (diff)

Changed 5 years ago by igloo

  • owner set to igloo

Thanks for the report; I'll fix this.

Changed 5 years ago by igloo

  • type changed from bug to merge
  • milestone set to 6.8.3
Fri Apr 25 06:10:30 PDT 2008  Ian Lynagh <igloo@earth.li>
  * Remove debugging prints that were accidentally left in

Changed 5 years ago by igloo

  • status changed from new to closed
  • resolution set to fixed

Merged

Changed 5 years ago by simonmar

  • architecture changed from Unknown to Unknown/Multiple
Note: See TracTickets for help on using tickets.