• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Best way to tell if a process is still running.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Best way to tell if a process is still running.


  • Subject: Re: Best way to tell if a process is still running.
  • From: Dalton Hamilton <email@hidden>
  • Date: Tue, 12 Dec 2006 12:27:34 -0500

Quinn -
Thanks for the response.  My comments are integrated below:


Tell me that you mean "daemon" here. Launching an app (even a non- GUI one) from cron would be bad.

I didn't use the word daemon because it really isn't a daemon. I think of a daemon as a process that runs in the background without an associated login terminal or login shell waiting for an event or waiting to perform some certain task on a periodic basis. This is just a simple app that reads in config data and starts an executable process passing it various parameters. I can make the code a daemon (setup to run forever) and then look into whatever mechanism OSX uses that is equivalent to the restart function of inittab -- maybe that is launchd.





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 like the kill() idea but my question here would be, how often is a PID re-used? Let's say a metricEngine creates a run file with pid of 1422 and then the process crashes without cleaning up the pid file. When could init re-use the pid of 1422 and assign it to some other process it starts???? If I'm sure another process can't be started with the pid of 1422 for some extended period of time, then the kill () solution would work.




btw Why cron and not launchd?

The reason why is because I haven't looked into launchd and cron has always worked really well for these type things. If I daemonize the meStarter, will launchd start it and keep an eye on it and if it isn't running, restart it??? A quick glance at http:// developer.apple.com/macosx/launchd.html talks about migrating from init.d at first glance, I didn't see the specific details saying it would restart a process if it dies.



Thanks Dalton Hamilton

_______________________________________________
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


  • Follow-Ups:
    • Re: Best way to tell if a process is still running.
      • From: Quinn <email@hidden>
References: 
 >Best way to tell if a process is still running. (From: Dalton Hamilton <email@hidden>)
 >Re: Best way to tell if a process is still running. (From: Quinn <email@hidden>)

  • Prev by Date: Interested in wireless programming
  • Next by Date: Re: Best way to tell if a process is still running.
  • Previous by thread: Re: Best way to tell if a process is still running.
  • Next by thread: Re: Best way to tell if a process is still running.
  • Index(es):
    • Date
    • Thread