diff --git a/examples/CLI/polykermacli.lpr b/examples/CLI/polykermacli.lpr index 9ad1ee8..697167d 100644 --- a/examples/CLI/polykermacli.lpr +++ b/examples/CLI/polykermacli.lpr @@ -192,16 +192,19 @@ procedure TPolyKermaCLI.DoRun; begin LoadParams; - PolyKermaSetup; - {$IFDEF UNIX} - if FpSignal(SigInt, @HandleSigInt) = signalhandler(SIG_ERR) then begin - Error({$I %FILE%}, {$I %LINE%}, Format('Failed to install signal error: %d', [ fpGetErrno ])); - Halt(1); + if not Terminated then + begin + PolyKermaSetup; + {$IFDEF UNIX} + if FpSignal(SigInt, @HandleSigInt) = signalhandler(SIG_ERR) then begin + Error({$I %FILE%}, {$I %LINE%}, Format('Failed to install signal error: %d', [ fpGetErrno ])); + Halt(1); + end; + {$ENDIF UNIX} + + FDispatcher.Run(True); + PolyKermaTearDown; end; - {$ENDIF UNIX} - - FDispatcher.Run(True); - PolyKermaTearDown; // stop program loop Terminate;