readln() blocks file operations on windows
Martin Drasar via Digitalmars-d
digitalmars-d at puremagic.com
Thu Jul 31 11:21:39 PDT 2014
Hi,
consider this code:
import std.stdio;
import std.concurrency;
import core.thread;
void tryOpen()
{
Thread.sleep(2.seconds);
try {
auto f = File("nonexistent");
}
catch (Exception e) {
writeln("Could not open a file");
}
}
void main()
{
spawn(&tryOpen);
readln();
}
On Linux, it works as expected, showing a "Could not open a file" after
two or so seconds. On windows, however, the file opening gets blocked
until a line is read from stdin.
Is this a feature or a bug? If it is a feature, it certainly is not
documented.
Cheers,
Martin
More information about the Digitalmars-d
mailing list