duplicating handles

Volker Stolz [email protected]
Wed, 18 Dec 2002 09:58:14 +0100


In local.glasgow-haskell-users, you wrote:
> Question about dupTo...you can use it to, for instance, redirect stdout to
> a file.  What if I want to have stuff that is printed to stdout to be
> redirect to a file *and also* printed to stdout.  I fooled around with a
> few combinations, but nothing seems to work.  Please help :)

This sounds like you're expecting that it's possible to create a setup
where one print statement will print to several file descriptors. That's
not (easily) possible [it is, but it's probably not worth the hassle: fork
a new process, 'hijack' stdout/stderr, let the new process read from this
fd and do with it whatever you want -- you'd still need one print statement
for each fd].

I suggest you either use indeed two print statements or 'tee' from the
shell commandline.
-- 
http://www-i2.informatik.rwth-aachen.de/stolz/ *** PGP *** S/MIME