Skip to content

BufferMode not preserved when handle goes through silence/capture #19

@mitchellwrosen

Description

@mitchellwrosen

This is probably a rare use case, but maybe one you didn't consider. I have a commandline app that sets stdout to NoBuffering in main. If I launch an external process and wish to silence it, I have to reset the BufferMode. Here's my workaround:

hSilence' :: [Handle] -> IO a -> IO a
hSilence' hs action = do
    bs <- mapM hGetBuffering hs
    result <- hSilence hs action
    mapM_ (\(h,b) -> hSetBuffering h b) (zip hs bs)
    return result

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions