Bad file descriptor for stdin

I have a program that’s been working for a while now on Mac, Windows, and Linux just fine. I recently went to start adding concurrency. Some things would be running in the background while the user enters commands from a simple prompt.

Sometime around this change - on Windows only - a simple call to s <- getLine suddenly stopped working and instead a window appears saying:

<stdin>: hGetLine: invalid argument (Bad file descriptor)

The code runs perfectly fine on Mac and Linux. And - in fact - the program runs fine on Windows via stack ghci and manually just running main from the REPL.

Does anyone know what would cause this issue to suddenly pop up and how I can fix it?

1 Like

This Stack Overflow answer mentions a similar error, although I don’t know if the cause will be the same. But perhaps you could try the suggested solution: invoke getLine outside the main thread, using withAsync.