I am using the GHC API extensively. The entire application is built on the GHC API, with the occasional bit of code practically stolen from GHCi :)
However, I don't know of a way to intercept stdin even if I am using the GHC API. Given a block of code, there is no sane static analysis than can be done to detect whether it reads from stdin, as far as I know.
Is there any way to check whether a process is blocked when reading from a Handle or an Fd? Maybe there are some low-level hacks with unsafeCoerce or something that would let me pass a non-handle as a Handle, and do it that way?
The only other option is just disabling all uses of stdin, or perhaps reimplementing myself the Prelude functions that use stdin. (But this would still break libraries that have already compiled in the Prelude versions.)