<feed xmlns='http://www.w3.org/2005/Atom'>
<title>src/lib/libutil/pidfile.c, branch releng/10.0</title>
<subtitle>FreeBSD source tree</subtitle>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/'/>
<entry>
<title>libutil: Use O_CLOEXEC for internal file descriptors from open().</title>
<updated>2013-08-28T21:10:37+00:00</updated>
<author>
<name>Jilles Tjoelker</name>
<email>jilles@FreeBSD.org</email>
</author>
<published>2013-08-28T21:10:37+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=d1d4d95209e4ba5da75c16a5653bc46fca6418f8'/>
<id>d1d4d95209e4ba5da75c16a5653bc46fca6418f8</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>When pidptr was passed as NULL to pidfile_open(3), we were returning</title>
<updated>2013-03-14T20:22:52+00:00</updated>
<author>
<name>Pawel Jakub Dawidek</name>
<email>pjd@FreeBSD.org</email>
</author>
<published>2013-03-14T20:22:52+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=36a00a3f38e7504ff63b0c638b0d692c424a8235'/>
<id>36a00a3f38e7504ff63b0c638b0d692c424a8235</id>
<content type='text'>
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 &lt;erdgeist@erdgeist.org&gt;
Reviewed by:	jhb, Dirk Engling &lt;erdgeist@erdgeist.org&gt;
MFC after:	1 week
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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 &lt;erdgeist@erdgeist.org&gt;
Reviewed by:	jhb, Dirk Engling &lt;erdgeist@erdgeist.org&gt;
MFC after:	1 week
</pre>
</div>
</content>
</entry>
<entry>
<title>Set the O_CLOEXEC flag when opening the pidfile to avoid leaking the</title>
<updated>2012-02-20T13:59:24+00:00</updated>
<author>
<name>Guy Helmer</name>
<email>ghelmer@FreeBSD.org</email>
</author>
<published>2012-02-20T13:59:24+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=fde4439701c797a5192e66202173fd331ec280f7'/>
<id>fde4439701c797a5192e66202173fd331ec280f7</id>
<content type='text'>
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.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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.
</pre>
</div>
</content>
</entry>
<entry>
<title>Using the O_CLOEXEC flag on open(2) caused the pidfile lock to be lost</title>
<updated>2012-02-06T14:11:24+00:00</updated>
<author>
<name>Guy Helmer</name>
<email>ghelmer@FreeBSD.org</email>
</author>
<published>2012-02-06T14:11:24+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=000d6ce28584b1d319be7e4449bf506f16fe5d58'/>
<id>000d6ce28584b1d319be7e4449bf506f16fe5d58</id>
<content type='text'>
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:~%
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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:~%
</pre>
</div>
</content>
</entry>
<entry>
<title>Move struct pidfh definition into pidfile.c, and leave a forward declaration</title>
<updated>2012-01-12T22:49:36+00:00</updated>
<author>
<name>Guy Helmer</name>
<email>ghelmer@FreeBSD.org</email>
</author>
<published>2012-01-12T22:49:36+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=47b3924be01208bd053c269fa4f52f9dc79035b7'/>
<id>47b3924be01208bd053c269fa4f52f9dc79035b7</id>
<content type='text'>
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.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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.
</pre>
</div>
</content>
</entry>
<entry>
<title>jilles pointed out that O_CLOEXEC could be used in the open(2) flags</title>
<updated>2012-01-11T16:35:26+00:00</updated>
<author>
<name>Guy Helmer</name>
<email>ghelmer@FreeBSD.org</email>
</author>
<published>2012-01-11T16:35:26+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=656b6da7e3a4f8373ae85f62419de8e6f54feb8a'/>
<id>656b6da7e3a4f8373ae85f62419de8e6f54feb8a</id>
<content type='text'>
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.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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.
</pre>
</div>
</content>
</entry>
<entry>
<title>Constify arguments.</title>
<updated>2012-01-11T00:31:04+00:00</updated>
<author>
<name>Pawel Jakub Dawidek</name>
<email>pjd@FreeBSD.org</email>
</author>
<published>2012-01-11T00:31:04+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=9de091f2efce4f45e2efe2afe054725b3c1dd2e5'/>
<id>9de091f2efce4f45e2efe2afe054725b3c1dd2e5</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Style fixes courtesy of pjd.</title>
<updated>2012-01-10T21:47:58+00:00</updated>
<author>
<name>Guy Helmer</name>
<email>ghelmer@FreeBSD.org</email>
</author>
<published>2012-01-10T21:47:58+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=4a25aa061a2afec2af21caa4f2187d8544b2ea18'/>
<id>4a25aa061a2afec2af21caa4f2187d8544b2ea18</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Add pidfile_fileno() to obtain the file descriptor for an open</title>
<updated>2012-01-10T19:53:25+00:00</updated>
<author>
<name>Guy Helmer</name>
<email>ghelmer@FreeBSD.org</email>
</author>
<published>2012-01-10T19:53:25+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=f295618d06dd1b215fcd963b33c1265acea36ac9'/>
<id>f295618d06dd1b215fcd963b33c1265acea36ac9</id>
<content type='text'>
pidfile.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
pidfile.
</pre>
</div>
</content>
</entry>
<entry>
<title>Set the FD_CLOEXEC flag on the open pidfile file descriptor.</title>
<updated>2012-01-10T18:43:27+00:00</updated>
<author>
<name>Guy Helmer</name>
<email>ghelmer@FreeBSD.org</email>
</author>
<published>2012-01-10T18:43:27+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=0dc6d4d19ca8657c7f6d7ee5b43f05ec1e018b84'/>
<id>0dc6d4d19ca8657c7f6d7ee5b43f05ec1e018b84</id>
<content type='text'>
Discussed with: pjd, des
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Discussed with: pjd, des
</pre>
</div>
</content>
</entry>
</feed>
