Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#2199 closed merge (fixed)

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: Test Case:
Blocked By: Blocking:
Related Tickets: Differential Revisions:

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)

Change History (6)

comment:1 Changed 7 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)

comment:2 Changed 7 years ago by igloo

  • Description modified (diff)
  • difficulty set to Unknown

comment:3 Changed 7 years ago by igloo

  • Owner set to igloo

Thanks for the report; I'll fix this.

comment:4 Changed 7 years ago by igloo

  • Milestone set to 6.8.3
  • Type changed from bug to merge
Fri Apr 25 06:10:30 PDT 2008  Ian Lynagh <[email protected]>
  * Remove debugging prints that were accidentally left in

comment:5 Changed 7 years ago by igloo

  • Resolution set to fixed
  • Status changed from new to closed

Merged

comment:6 Changed 7 years ago by simonmar

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