On Sat, 2007-02-10 at 09:32 +1100, John Ky wrote:
Hi,
I noticed on Windows that when I use IO functions that write to stdout when the process is lacking a console, those functions throw an IOError. I'm not sure if this also occurs for stderr because I haven't tried it.
Some classes of processes are created without a console because they never interact with the user and include System services. Crashing with IOError in this case is difficult to diagnose because because the only symptom is the process crashes with no visible output.
I believe the most sensible behaviour should be for those functions to not throw, but instead do nothing.
I brought this up some time ago with the GHC developers since it is a problem for Windows users who use Gtk2Hs and want to hide the console window. They felt that since this was the default system behaviour that it's best for GHC not to override that. C programs apparently suffer from the same problem (possibly depending on the variant of the C lib). The situation is much improved from when I originally complained about this. It does now at least display an message box with the error rather than silently terminating. If there is a reliable way to 'fix' the standard handles (as Paul Moore suggests) when running without a console then I could include that code into the Gtk2Hs startup and then make -optl-mwindows the default for progs compiled with Gtk2Hs. Duncan