Hey Guys, I've another question I couldn't find an answer on the internet. I hope you can help me.
I'm writing an Cocoa Application which runs in background and does several tasks for me. If I quit the application, I show a NSAlert. That all works great. But here comes my problem. This Alert is presented from inside the applicationShouldTerminate:
Method. So if I Logout, this method is triggered and the alert is shown. But OSX quits the application and logs out without waiting for a response even if I return NSTerminateCancel
.
How can I force the OS to stop logging out/shutting down from within my application, so that the user (myself :-D) can decide what to do. (It just a dialog which asks if the done work shall be sa开发者_StackOverflow社区ved or not.)
I hope you can help me...
Sandro
Mac OS X is based on UNIX. When a system shuts down, the SIGKILL signal is send that terminates all the processes. But before that, the SIGTERM signal is sent that informs the processes that a shutdown is going to take place.
I think the solution lies in handling of the signals, i.e. detecting and blocking them. Regarding this, you may find guidance in GNU C Library: Signal Handling: Blocking Signals.
The examples there maybe about BSD, but you may know that the OS X core is derived from BSD and therefore OS X supports it. Moreover, C is supported in Objective-C.
精彩评论