On Mon, Mar 18, 2013 at 6:47 AM, Erwin Namal <erwin.namal@gmail.com> wrote:
Have you read this?
Yes, this is where they explain all about the plists. It is very well documented, but doesn't answer my questions which are: - How to set up my project to use Objective-C for my daemon. - What does my Objective-C entry point look like (int main(…) ?)
Basically, structure it the same wait that you thought, but instead of using a sleep(), use kqueue() to receive events from the kernel. When there are no events, your process stays suspended.
- How do I handle SIGKILL
You cannot. SIGKILL, by definition, is not handle-able. If sent to your process, your process will never receive it, but it will stop running and be removed from memory. Therefore, if you have any resources that you need to shut down or close in a special way, it's critical that you do so in the timeframe allotted between the TERM and the KILL.
- If I can't use a for/while/etc. loop, how do I prevent my daemon from exiting once the main function returns?
Set up kqueue() prior to your loop, then call it at the top of your loop and use a switch statement (or multiple if/else conditions) to handle each type of event coming back from kqueue(). After you've handled one event, you can loop back to call kqueue() again, for the next event. _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.app... This email sent to site_archiver@lists.apple.com
participants (1)
-
Tilghman Lesher