On 8/14/06, Bryan Irvine <[EMAIL PROTECTED]> wrote: > I'm trying to write a simple daemon. My first real C program so go > easy on me. ;) > > I'm trying to get the daemon to not start a second copy (if someone > were to try). What's the best way to do something like that? Check > the pid file?
I assume you are using Unix or similar (Linux, OSX), since you don't specify. Simplest thing, for a simple daemon, is to create a file containing the pid, lock it and remove the file when the process exits. This does create problems if the daemon exits abnormally (like a segfault) and doesn't clean up after itself. There are more advanced things you can do, perhaps using a semphore or mutex, but I'd go the easier route first. -- Brett McCoy: Programmer by Day, Guitarist by Night http://www.alhazred.com http://www.cassandrasyndrome.com http://www.revelmoon.com To unsubscribe, send a blank message to <mailto:[EMAIL PROTECTED]>. Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/c-prog/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
