| 1 |
|
| 2 |
// https://issues.dlang.org/show_bug.cgi?id=20256 |
| 3 |
|
| 4 |
extern(C) __gshared string[] rt_options = [ "gcopt=parallel:1" ]; |
| 5 |
|
| 6 |
void main() |
| 7 |
{ |
| 8 |
version (Posix) |
| 9 |
{ |
| 10 |
import core.sys.posix.signal; |
| 11 |
import core.sys.posix.unistd; |
| 12 |
import core.thread; |
| 13 |
import core.memory; |
| 14 |
|
| 15 |
sigset_t m; |
| 16 |
sigemptyset(&m); |
| 17 |
sigaddset(&m, SIGHUP); |
| 18 |
|
| 19 |
auto x = new int[](10000); |
| 20 |
foreach (i; 0 .. 10000) |
| 21 |
{ |
| 22 |
x ~= i; |
| 23 |
} |
| 24 |
GC.collect(); // GC create thread |
| 25 |
|
| 26 |
sigprocmask(SIG_BLOCK, &m, null); // block SIGHUP from delivery to main thread |
| 27 |
|
| 28 |
auto parent_pid = getpid(); |
| 29 |
auto child_pid = fork(); |
| 30 |
assert(child_pid >= 0); |
| 31 |
if (child_pid == 0) |
| 32 |
{ |
| 33 |
kill(parent_pid, SIGHUP); // send signal to parent |
| 34 |
_exit(0); |
| 35 |
} |
| 36 |
// parent |
| 37 |
Thread.sleep(100.msecs); |
| 38 |
// if we are here, then GC threads didn't receive SIGHUP, |
| 39 |
// otherwise whole process killed |
| 40 |
_exit(0); |
| 41 |
} |
| 42 |
} |