cocoa - What is the correct way to self-terminate a MacOS XPC service? -


I have successfully followed the tutorial, together with sandboxify sample code and an active client / service Setup is using the new NSXPCConnection class.

It is still not completely clear to me that once the work is done then the service application itself has to be corrected. I understand that in many cases, the service is expected to survive, but in the case of use I have been kept in mind, this service will be used only for processing which I have not done otherwise in the main application. Once the processing has finished, there is no reason for the service application to stay, if the client requires another service on a different date, then it can only rebuild a new one

Since this service is light, non-essay, NSApplication , I was trying to terminate myself by calling invalid inside application current , But almost every time an EXC_BAD_ACCESS exception is turned on Invalid calling on [NSXPCListener serviceListener] generates little crashes, but it still crashes on NSXPCConnection Almost every time EXC_BAD_ACCESS generates exceptions, invalid calling from within the client application

So I'm curious that the right sequence of the phase is called XPC service What to do to stop and then to exit the service application, ideally Customers will be the last XPC call after call to customer end itself.

The attachment is a small screenshot that looks like one of the exception trajectories. (Yes, it's a webview that is loading in the service. Once the webwolove is loaded, I want to end the service myself)

 Enter image details here

My The first reaction is that you should not be bothered to end when the memory is pressurized and your service is useless, the launch will kill your service. Probably does not come in the best interest of someone, because it will take time to re-launch your service, do not end it and you do not have to understand why your attempt is crashing.

But if for some reason you want to end, do not work hard. Just do whatever you need to clean (flush buffers, close network connection to the server so beautifully Do not harm, whichever is done) and exit the call, although you seem to be using NSApplication, your service is not an application in any way that the user pays attention to it and in some way There is no concrete reason to work. The host application needs to be able to deal with the crash of your service, so knowingly exclusively to exit the exit is fine.

By the way, using NSAPTation in the XPC service is probably not the best idea because there is no supported way of declaring that you want to. It can help you to understand why this is not working for you, but this paragraph should not be considered as a proper analysis of the accident. : -)

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -