tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: pidfile_lock(3)
On Sun, Mar 20, 2016 at 08:43:31PM -0400, Thor Lancelot Simon wrote:
> On Sun, Mar 20, 2016 at 08:53:03PM +0000, Roy Marples wrote:
> > On Sunday 20 March 2016 14:53:46 you wrote:
> > > On Sat, 19 Mar 2016 23:29:37 +0000
> > >
> > > Roy Marples <roy%marples.name@localhost> wrote:
> > > > pidfile(3) is pretty crap - it just writes to the file without any
> > > > locking.
> > >
> > > I don't understand why you think any of that matters. Locks only
> > > advisory anyway. Any noncooperating process can (with sufficient
> > > privilege) overwrite the file. What cooperating process do you imagine
> > > would honor a lock on a pidfile?
> >
> > So it honors it's own lock to avoid user stupidity of starting the same daemon
> > more than once. This is the primary goal of the function.
>
> That's the wrong way to do it, because it does not work reliably on NFS.
> You can take advantage of O_CREAT|O_EXCL or rename() semantics to do the
> same thing but in a much more robust way.
It works correctly on NFS if you have the locking daemon setup? Besides,
is there even a valid reason for using NFS for pidfiles? I would expect
/var/run to be a minimal tmpfs in that kind of installations.
Joerg
Home |
Main Index |
Thread Index |
Old Index