Detecting SIGINT in Console process

I have a xojo console tool which is being run as a child from within a Swift Process.

The Swift Process has two ways of terminating the child:
https://developer.apple.com/documentation/foundation/process

  • terminate - which sends SIGTERM
  • interrupt - which sends SIGINT

Is it possible to detect these from within the Xojo console app?

You can use SignalHandlerMBS class in MBS Xojo Util Plugin.

Yes!

See the solution in Feedback here:

<https://xojo.com/issue/2332>

1 Like

That works, thanks!

Of note, the signal handler function must be a global method; I tried to make it a method on the Application class, but that would crash in RuntimeUnlockObject.

How would one do that for TargetWindows?

Those example are for macOS/Linux…

And those examples don’t seem to be for Windows, too…

So while I can get this working for macOS/Linux, I’m still looking for a way to detect this (e.g. pressing “Ctrl + C”) on TargetWindows so that I can do some cleanup before the Xojo console/service app is being quit…

Does this help you Jurg?

[LINK REMOVED PER OP REQUEST]

2 Likes

It does :wink:
Thanks a lot for your example project for TargetWindows…!

How about adding this example to <https://xojo.com/issue/2332>?
Then there would be example for all Targets… both for Devs looking for a solution now, and for Xojo to implement this via their Framework.

1 Like