
5 Jan
2014
5 Jan
'14
12:46 p.m.
Hello all, I need to do something strange and terrible in Haskell: intercept `stdin`. In other words, I need to detect (in another thread, probably?) when my running program is trying to read from `stdin`, and then feed it some data. I know I can use `hDupTo` and other similar things to replace the stdin handle with my own handle, and I know I could probably use `createPipe` or similar from the `unix` package in order to write things to these handles, but I have no idea how I might go about detecting that a handle is being read from. Any ideas? I've racked my brain and cannot come up with a way to do this. I am using the GHC API elsewhere if that leads to any sort of crazy hackery that might save the day. -- Andrew