Program crash: GC destroys an object unexpectedly
eugene
dee0xeed at gmail.com
Thu Sep 23 18:10:05 UTC 2021
On Thursday, 23 September 2021 at 17:53:00 UTC, eugene wrote:
> On Thursday, 23 September 2021 at 17:49:43 UTC, eugene wrote:
>> On Thursday, 23 September 2021 at 17:20:18 UTC, Steven
>> Schveighoffer wrote:
>>> 1. ctrl-c, signal handler triggers, shutting down the loop
>>> 2. main exits
>>> 3. GC finalizes all objects, including the Stopper and it's
>>> members
>>
>> but both SIGINT and SIGTERM are still **blocked**,
>> they just will not reach the process.
>
> oops..
no oops, that's all right.
- when creating Signal instance, corresponding signal becames
blocked
```d
final class Signal : EventSource {
enum int sigInt = SIGINT;
enum int sigTerm = SIGTERM;
ulong number;
this(int signo) {
super('S');
sigset_t sset;
sigset_t old_sset;
/* block the signal */
sigemptyset(&sset);
sigaddset(&sset, signo);
sigprocmask(SIG_BLOCK, &sset, &old_sset);
id = signalfd(-1, &sset, SFD_CLOEXEC);
```
- upon receiving SIGINT stopperIdleS0() is called.
now stop variable of EventQueue is false
- next call to wait() method just return.
(remember, signals are still blocked)
More information about the Digitalmars-d-learn
mailing list