Re: Several Questions
Re: Several Questions
- Subject: Re: Several Questions
- From: Gwynne Raskind <email@hidden>
- Date: Sun, 31 May 2009 14:27:59 -0400
On May 31, 2009, at 2:08 PM, Ammar Ibrahim wrote:
Can you give us so more details? For example: What will the app do?
Your description is very strange, lol.
But indeed, you should create a normal cocoa app that do the stuff
you
want to do (UI + the real stuff),
and a little daemon that checks every X minutes if the other app is
running:
yes: ok, continue
no: start app (log message? App was stopped)
Look at CFNotification and the distributed notification center (I
thought
there was a Cocoa variant of that, but I can't seem to find it) for
a way to
detect whether your app has hung. You could just do a ping/pong set
of
question/reply notifications that your daemon sends to your app and
gets a
reply. If the app is still running but there's no reply within a
sensible
timeframe, something has gone wrong.
This seems like a very doable approach. Anyhow, the daemon itself
might
crash, so I would go for a cron job that runs say every 5 mins,
Now let's assume the app was running and not responding, I couldn't
find any
API to "force quit" another application. Would a `kill -9 {process
ID}` be
sufficient?
The Cocoa variant of the distributed notification is
NSDistributedNotificationCenter :).
"kill -9 {process ID}" is shell-ese for the POSIX call kill(2) with a
parameter of SIGKILL:
NAME
kill -- send signal to a process
SYNOPSIS
#include <signal.h>
int
kill(pid_t pid, int sig);
The rest of the manpage has more info if you need it.
Note that OS X's Force Quit command doesn't send SIGKILL immediately;
I believe it sends SIGINT and SIGQUIT before resorting to SIGKILL,
since a process can trap SIGINT and SIGQUIT, use them to perform
emergency cleanup before dying, or even just ignore them completely.
SIGKILL can not be trapped, caught, ignored, or otherwise stopped from
terminating the process.
-- Gwynne
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden