If stdout is __gshared, why does this throw / crash?
    Atila Neves via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Sat Mar  5 06:18:31 PST 2016
    
    
  
With a small number of threads, things work as intended in the 
code below. But with 1000, on my machine it either crashes or 
throws an exception:
import std.stdio;
import std.parallelism;
import std.range;
void main() {
     stdout = File("/dev/null", "w");
     foreach(t; 1000.iota.parallel) {
         writeln("Oops");
     }
}
I get, depending on the run, "Bad file descriptor", "Attempting 
to write to a closed file", or segfaults. What am I doing wrong?
Atila
    
    
More information about the Digitalmars-d-learn
mailing list