On 2015-05-07 18:15, Dmitri wrote:
I'm a D noob, so my question is perhaps naive. At work, we develop
servers that are 24/7 and as such they don't have a clean exit path.
Sometimes, however, I'd like to troubleshoot a process and use valgrind,
in which case I have to come with a way of forcing a program's exit.

I know I can control (some) valgrind tools from outside by forcing a
log, but it is not always the case. So more often than not, I end up
adding some sort of debugging code to be able to force an exit from
outside - in which case it is as simple as calling stdlib's exit. This
poses a problem when the exit is called from a thread other than the
main one, since it did not have a _d_dos_registry on the way "in", but
it gets called on the way "out" and crashes when the _tlsRanges is
modified.

My questions are,
   * is it legit to want to terminate not from the main thread?
   * if not, what is the recommended simpler way of doing it?

I would recommend trying to avoid using "exit" to terminate the application. Something is keeping the process alive since it's running 24/7, like an endless loop. Try adding a condition to this loop then have a way to communicate this condition is changed to the process. One way of doing this would be to send a signal to the process which it handles and set this condition to false. The loop will exit and the process terminates in the usual way by running to the end.

--
/Jacob Carlborg

Reply via email to