Re: Best way to tell if a process is still running.
Re: Best way to tell if a process is still running.
- Subject: Re: Best way to tell if a process is still running.
- From: Quinn <email@hidden>
- Date: Tue, 12 Dec 2006 16:43:26 +0000
At 11:24 -0500 12/12/06, Dalton Hamilton wrote:
I have a non-gui app
Tell me that you mean "daemon" here. Launching an app (even a
non-GUI one) from cron would be bad.
However, I know this must be a common task and was wondering if
anyone else has thought of a nice way to accomplish this.
My favourite tricks for this are:
A. Create a UNIX domain socket between the processes. When one end
dies, the other end becomes readable [1], which you can monitor via
select or kqueues.
B. You can use kill to determine if a PID is still valid. If you
kill(pid, 0), you either get 0 (process exists and you can send it
signals), ESRCH (no process exists) or EPERM (process exists but you
can't send it signals). Armed with that knowledge, you can just use
the standard trick of dumping a PID to a .run file.
I don't think option A will work for you because you don't have a
single process that lives all the time.
btw Why cron and not launchd?
S+E
--
Quinn "The Eskimo!" <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
[1] Yes, readable. That's just a crazy UNIXism. Actually, it kinda
makes sense because, when you read from the socket, you get an 0
indicating EOF.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden