#
272461 |
|
02-Oct-2014 |
gjb |
Copy stable/10@r272459 to releng/10.1 as part of the 10.1-RELEASE process.
Approved by: re (implicit) Sponsored by: The FreeBSD Foundation |
#
256281 |
|
10-Oct-2013 |
gjb |
Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.
Approved by: re (implicit) Sponsored by: The FreeBSD Foundation
|
#
255007 |
|
28-Aug-2013 |
jilles |
libutil: Use O_CLOEXEC for internal file descriptors from open().
|
#
248281 |
|
14-Mar-2013 |
pjd |
When pidptr was passed as NULL to pidfile_open(3), we were returning EAGAIN/EWOULDBLOCK when another daemon was running and had the pidfile open. We should return EEXIST in that case, fix it.
Reported by: Dirk Engling <erdgeist@erdgeist.org> Reviewed by: jhb, Dirk Engling <erdgeist@erdgeist.org> MFC after: 1 week
|
#
231938 |
|
20-Feb-2012 |
ghelmer |
Set the O_CLOEXEC flag when opening the pidfile to avoid leaking the file descriptor via exec(3).
Now that daemon(8) has been fixed to resolve the issue noted by trociny, the consensus is that this change should be OK.
|
#
231087 |
|
06-Feb-2012 |
ghelmer |
Using the O_CLOEXEC flag on open(2) caused the pidfile lock to be lost when the child process execs daemon's target program thanks to flock(2) semantics. So, we apparently have to leak the open pidfile's file descriptor to keep the lock for the pidfile(3) functions to work properly.
Test case demonstrated by trociny:
ref8-amd64:/home/trociny% uname -r 8.2-STABLE ref8-amd64:/home/trociny% daemon -p /tmp/sleep.pid sleep 10 ref8-amd64:/home/trociny% daemon -p /tmp/sleep.pid sleep 10 daemon: process already running, pid: 19799
kopusha:~% uname -r 10.0-CURRENT kopusha:~% daemon -p /tmp/sleep.pid sleep 10 kopusha:~% daemon -p /tmp/sleep.pid sleep 10 kopusha:~%
|
#
230037 |
|
12-Jan-2012 |
ghelmer |
Move struct pidfh definition into pidfile.c, and leave a forward declaration for pidfh in libutil.h in its place. This allows us to hide the contents of the pidfh structure, and also allowed removal of the "#ifdef _SYS_PARAM_H" guard from around the pidfile_* function prototypes.
Suggested by pjd.
|
#
229966 |
|
11-Jan-2012 |
ghelmer |
jilles pointed out that O_CLOEXEC could be used in the open(2) flags rather than using fcntl(2) later, and in addition to saving a system call, removes a possible race with fork/exec from threads or signal handlers.
|
#
229951 |
|
10-Jan-2012 |
pjd |
Constify arguments.
|
#
229942 |
|
10-Jan-2012 |
ghelmer |
Style fixes courtesy of pjd.
|
#
229937 |
|
10-Jan-2012 |
ghelmer |
Add pidfile_fileno() to obtain the file descriptor for an open pidfile.
|
#
229936 |
|
10-Jan-2012 |
ghelmer |
Set the FD_CLOEXEC flag on the open pidfile file descriptor.
Discussed with: pjd, des
|
#
226450 |
|
16-Oct-2011 |
pjd |
In pidfile_open(), if the pidfile is locked, but empty (PID is not stored yet) and the caller requested other process' PID by passing non-NULL pidptr argument, we will wait at most 100ms for the PID to show up in the file and if it won't, we will store -1 in *pidptr.
From now on, pidfile_open() function never sets errno to EAGAIN on failure.
In collaboration with: des MFC after: 1 week
|
#
184091 |
|
20-Oct-2008 |
des |
There is no point in releasing a lock on a file which we've unlinked and are about to close, so don't. As a bonus, pidfile_remove(3) will now work with an fcntl(2)-based flopen(3).
|
#
172577 |
|
12-Oct-2007 |
kib |
When pidfile is already locked and has zero length, do not return success and zero pid from pidfile_read(). Return EAGAIN instead. Sleep up to three times for 5 ms while waiting for pidfile to be written.
mount(8) does the kill(mountpid, SIGHUP). If mountd pidfile is truncated, that would result in the SIGHUP delivered to the mount' process group instead of the mountd.
Found and analyzed by: Peter Holm Tested by: Peter Holm, kris Reviewed by: pjd MFC after: 1 week
|
#
171706 |
|
03-Aug-2007 |
des |
Back out previous commit until I figure out why my regression test fails.
Approved by: re (kensmith)
|
#
171705 |
|
03-Aug-2007 |
des |
Use fcntl(2)-style locks instead of less-portable flock(2)-style locks.
Approved by: re (kensmith)
|
#
169468 |
|
11-May-2007 |
des |
strlcpy() may be faster than snprintf(), but it is less portable, and this is not performance critical code anyway. Also, avoid using strlen() to obtain information which we already have.
MFC after: 3 weeks
|
#
169448 |
|
10-May-2007 |
des |
Use flopen(3).
MFC after: 3 weeks
|
#
159874 |
|
22-Jun-2006 |
brian |
Remove some unused variables
|
#
157671 |
|
11-Apr-2006 |
jmg |
use pwrite to always write at the begining of the file.. If multiple calls to pidfile_write happen, the pidfile will have nul characters prepended due to the cached file descriptor offset...
Reviewed by: scottl MFC after: 3 days
|
#
149423 |
|
24-Aug-2005 |
pjd |
Add a family of functions for reliable pidfiles handling.
Idea from: jmg Discussed on: arch@
|