tst2005googlecode / umurmur

Automatically exported from code.google.com/p/umurmur
1 stars 0 forks source link

Fix PID file support (again) #19

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Now that we have privilege dropping support, we need to apply further fixes to 
the PID file handling.

Consider this situation:
   1.) uMurmur is started as root
   2.) It writes the PID file
   3.) It drops privileges
   4.) Eventually, uMurmur is killed
   5.) uMurmur tries to unlink the PID file.
       This will fail, since the PID file belongs to root :)

OTOH, if we don't unlink the PID file on shutdown, opening it with O_EXCL will 
not be sufficient to prevent multiple uMurmur instances from running (since the 
open would just fail).

Another way to prevent multiple instances is to lock the PID file while uMurmur 
is running -- which is what this patch does.

Note that we still try to unlink the PID file on shutdown -- it doesn't do no 
harm either way :)

Original issue reported on code.google.com by tilm...@googlemail.com on 23 Jan 2011 at 4:10

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by fatbob.s...@gmail.com on 23 Jan 2011 at 8:24

GoogleCodeExporter commented 9 years ago
Looking good to me. Committed in r155.
Thanks!

Original comment by fatbob.s...@gmail.com on 23 Jan 2011 at 8:32