[Haskell-beginners] redirect stdout to /dev/null

Magnus Therning magnus at therning.org
Sun Oct 4 01:56:55 EDT 2009


On Sat, Oct 03, 2009 at 04:43:25PM -0500, Hong Yang wrote:
> On UNIX, we can easily redirect stdout to /dev/null in a Shell. How is this
> realized in Haskell on both UNIX and Windows?

I'm not sure about Windows, but in Unix you'd close stdout, open /dev/null and
then call dup2() (System.Posix.IO.dupTo) to duplicate the newly opened Fd to
stdout (1).

> I used a library which gave me unwanted stdout display. I tried to find any
> function to hide the stdout output, but could not. Can someone help me out?
> 
> Otherwise I have to modify the code in the library to comment out some print
> commands.

I would strongly encourage you to modify the library.  It can be argued that
it's rather poor library design to not let the user control where output goes.

/M

-- 
Magnus Therning                        (OpenPGP: 0xAB4DFBA4)
magnus@therning.org          Jabber: magnus@therning.org
http://therning.org/magnus         identi.ca|twitter: magthe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/beginners/attachments/20091004/d01b6f26/attachment.bin


More information about the Beginners mailing list