Re: Single-instance daemons

2008-11-16 Thread Дамјан Георгиевски
> As per Stevens/Rago, "file and record locking provides a convenient > mutual-exclusion mechanism". On linux (at least) there's one nice trick to get a single-instance program. Create a unix domain socket, and bind it to an address that begins with the null character '\0'. You can bind the sa

Re: Single-instance daemons

2008-11-13 Thread Cameron Simpson
On 12Nov2008 22:30, Jeffrey Barish <[EMAIL PROTECTED]> wrote: | Cameron Simpson wrote: | > Or, more simply, get root to make an empty pid file once and chown it to | > the daemon user. Then the daemon can rewrite the file as needed. You need | > to move to truncating the file instead of removing it

Re: Single-instance daemons

2008-11-12 Thread Irmen de Jong
Jeffrey Barish wrote: Nice. One thing: how do I get the uid and gid for the target user? In general, I know the name of the target user, but the uid/gid assigned by the OS to that user could be different on different systems. pwd.getpwnam grp.getgrnam --irmen -- http://mail.python.org/mailm

Re: Single-instance daemons

2008-11-12 Thread Jeffrey Barish
Cameron Simpson wrote: > Or, more simply, get root to make an empty pid file once and chown it to > the daemon user. Then the daemon can rewrite the file as needed. You need > to move to truncating the file instead of removing it on daemon shutdown, > but that is trivial. And no mucking with privi

Re: Single-instance daemons

2008-11-12 Thread Jeffrey Barish
Jeff McNeil wrote: > Sure, start the daemon as root, write the appropriate files, and then > drop permissions using os.setegid and then os.seteuid. You can chown > the file before priv. drop to your target user so that it can be > removed when your exit handlers run.  Alternatively, you can reclai

Re: Single-instance daemons

2008-11-12 Thread Cameron Simpson
On 12Nov2008 14:07, Jeff McNeil <[EMAIL PROTECTED]> wrote: | On Nov 12, 4:57 pm, Jeffrey Barish <[EMAIL PROTECTED]> wrote: | > As per Stevens/Rago, "file and record locking provides a convenient | > mutual-exclusion mechanism". They note the convention of putting the lock | > file in /var/run in a

Re: Single-instance daemons

2008-11-12 Thread Jeff McNeil
On Nov 12, 4:57 pm, Jeffrey Barish <[EMAIL PROTECTED]> wrote: > As per Stevens/Rago, "file and record locking provides a convenient > mutual-exclusion mechanism". They note the convention of putting the lock > file in /var/run in a file called .pid, where is the name of > the daemon and content i