File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -145,6 +145,10 @@ proc waitStopSignals*(_: type ProcessState) {.async: (raises: [CancelledError]).
145145 # #
146146 # # Only one thread should ever listen for stop signals this way.
147147
148+ # Ensure other threads don't cause a crash, in case the application did not
149+ # already call it
150+ ProcessState .setupStopHandlers ()
151+
148152 let
149153 sigint = waitSignal (chronos.SIGINT )
150154 sigterm = waitSignal (chronos.SIGTERM )
@@ -164,10 +168,15 @@ proc waitStopSignals*(_: type ProcessState) {.async: (raises: [CancelledError]).
164168
165169 processState.store (ProcessState .Stopping , moRelaxed)
166170 finally :
171+ # waitSignal sometimes overwrites signal handlers:
172+ # https://github.com/status-im/nim-chronos/issues/581
173+ ProcessState .setupStopHandlers ()
174+
167175 # Might be finished already, which is fine..
168176 await noCancel sigint.cancelAndWait ()
169177 await noCancel sigterm.cancelAndWait ()
170178
179+
171180proc running * (_: type ProcessState ): bool =
172181 processState.load (moRelaxed) == ProcessState .Running
173182
You can’t perform that action at this time.
0 commit comments