[Haskell-cafe] How to Hijack stdin,err,out, thread safely?

Magnus Therning magnus at therning.org
Tue Jun 30 19:04:35 UTC 2015


On Wed, Jul 01, 2015 at 03:27:46AM +0900, Hiromi ISHII wrote:
> Hi,
> 
> I'm currently writing a web app to check the spec of input code
> usging QuickCheck.
> quickCheck* functions writes results to stderr & stdout, but I
> don't want them written to the app's original stdout/err.
> (I'm using SafeHaskell features to avoid malicious code executed,
> so don't worry about that :-))
> 
> So I want to execute I/O action hijacking stdout/err in a thread-safe manner.
> For example, I need function like below:
> 
> censorHandles :: IO a -> IO (a, String, String)
> censorHandles = ...
> 
> or
> 
> withStd :: Handle -> Handle -> Handle -> IO a -> IO a
> withStd = ...

Just to make sure, you have set `chatty` to false and passed it to one
of the other QuickCheck runners, right?

http://hackage.haskell.org/package/QuickCheck-2.8.1/docs/Test-QuickCheck.html#t:Args

I haven't used it myself, but I was under the impression that's how
one controls the use of stderr/stdout (well, at least stdout).

/M

-- 
Magnus Therning                      OpenPGP: 0xAB4DFBA4 
email: magnus at therning.org   jabber: magnus at therning.org
twitter: magthe               http://therning.org/magnus

Do not meddle in the affairs of Wizards, for they are subtle and quick
to anger.
     -- J.R.R Tolkien
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 163 bytes
Desc: not available
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20150630/f1aec4f4/attachment.sig>


More information about the Haskell-Cafe mailing list