aboutsummaryrefslogtreecommitdiff
path: root/libphobos/testsuite/libphobos.gc/forkgc2.d
blob: de7796ced72d0f93f6f2963b2b3fac2cdeb6dbf1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import core.stdc.stdlib : exit;
import core.sys.posix.sys.wait : waitpid;
import core.sys.posix.unistd : fork;
import core.thread : Thread;

void main()
{
    foreach (t; 0 .. 10)
        new Thread({
            foreach (n; 0 .. 100)
            {
                foreach (x; 0 .. 100)
                    new ubyte[x];
                auto f = fork();
                assert(f >= 0);
                if (f == 0)
                    exit(0);
                else
                    waitpid(f, null, 0);
            }
        }).start();
}