I am trying to add graceful shutdown support to a test harness. In the test harness, a server class consumes a thread to accept connections and service them. In order to stop the server, it has to be interrupted. This interruption mechanism is based on core.sync.condition.

I want to add a signal handler so that if SIGINT is received, the server is interrupted and stops gracefully.

In going through the signal documentation it looks like the signal handler must be a "nothrow @nogc" variety. Makes sense - there's very little you can do in a signal handler.

I tried carrying this down through to a class that ends up calling core.sync.condition.Condition.notifyAll(), however that method is not declared as "nothrow @nogc", therefore I assume that means I cannot use core.sync.condition.Condition from a signal handler. It would seem to me that a notify mechanism in a condition variable implementation perhaps could throw, but I wouldn't expect it to do any garbage collection.

How is one supposed to intercept SIGINT and notify a condition variable? Is this a deficiency in the standard library?

- Jim

Reply via email to