pidfile.3 (3dca093960479618c24f8b6470402fd6f216803f) | pidfile.3 (cb7cd07a0756ad4913c256d831461658e02e1249) |
---|---|
1.\" Copyright (c) 2005 Pawel Jakub Dawidek <pjd@FreeBSD.org> 2.\" All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. --- 10 unchanged lines hidden (view full) --- 19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23.\" SUCH DAMAGE. 24.\" 25.\" $FreeBSD$ 26.\" | 1.\" Copyright (c) 2005 Pawel Jakub Dawidek <pjd@FreeBSD.org> 2.\" All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. --- 10 unchanged lines hidden (view full) --- 19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23.\" SUCH DAMAGE. 24.\" 25.\" $FreeBSD$ 26.\" |
27.Dd August 22, 2005 | 27.Dd October 20, 2008 |
28.Dt PIDFILE 3 29.Os 30.Sh NAME 31.Nm pidfile_open , 32.Nm pidfile_write , 33.Nm pidfile_close , 34.Nm pidfile_remove 35.Nd "library for PID files handling" --- 10 unchanged lines hidden (view full) --- 46.Fn pidfile_close "struct pidfh *pfh" 47.Ft int 48.Fn pidfile_remove "struct pidfh *pfh" 49.Sh DESCRIPTION 50The 51.Nm pidfile 52family of functions allows daemons to handle PID files. 53It uses | 28.Dt PIDFILE 3 29.Os 30.Sh NAME 31.Nm pidfile_open , 32.Nm pidfile_write , 33.Nm pidfile_close , 34.Nm pidfile_remove 35.Nd "library for PID files handling" --- 10 unchanged lines hidden (view full) --- 46.Fn pidfile_close "struct pidfh *pfh" 47.Ft int 48.Fn pidfile_remove "struct pidfh *pfh" 49.Sh DESCRIPTION 50The 51.Nm pidfile 52family of functions allows daemons to handle PID files. 53It uses |
54.Xr flock 2 | 54.Xr flopen 3 |
55to lock a pidfile and detect already running daemons. 56.Pp 57The 58.Fn pidfile_open 59function opens (or creates) a file specified by the 60.Fa path | 55to lock a pidfile and detect already running daemons. 56.Pp 57The 58.Fn pidfile_open 59function opens (or creates) a file specified by the 60.Fa path |
61argument and locks it with the 62.Xr flock 2 63system call. | 61argument and locks it. |
64If a file can not be locked, a PID of an already running daemon is returned in 65the 66.Fa pidptr 67argument (if it is not 68.Dv NULL ) . 69The function does not write process' PID into the file here, so it can be 70used before 71.Fn fork Ns ing --- 156 unchanged lines hidden (view full) --- 228.El 229.Pp 230The 231.Fn pidfile_remove 232function may also fail and set 233.Va errno 234for any errors specified for the 235.Xr close 2 , | 62If a file can not be locked, a PID of an already running daemon is returned in 63the 64.Fa pidptr 65argument (if it is not 66.Dv NULL ) . 67The function does not write process' PID into the file here, so it can be 68used before 69.Fn fork Ns ing --- 156 unchanged lines hidden (view full) --- 226.El 227.Pp 228The 229.Fn pidfile_remove 230function may also fail and set 231.Va errno 232for any errors specified for the 233.Xr close 2 , |
236.Xr flock 2 , | |
237.Xr fstat 2 , 238.Xr write 2 , 239and 240.Xr unlink 2 | 234.Xr fstat 2 , 235.Xr write 2 , 236and 237.Xr unlink 2 |
241calls. | 238system calls and the 239.Xr flopen 3 240library function. |
242.Sh SEE ALSO | 241.Sh SEE ALSO |
243.Xr flock 2 , | |
244.Xr open 2 , | 242.Xr open 2 , |
245.Xr daemon 3 | 243.Xr daemon 3 , 244.Xr flopen 3 |
246.Sh AUTHORS 247.An -nosplit 248The 249.Nm pidfile 250functionality is based on ideas from 251.An John-Mark Gurney Aq jmg@FreeBSD.org . 252.Pp 253The code and manual page was written by 254.An Pawel Jakub Dawidek Aq pjd@FreeBSD.org . | 245.Sh AUTHORS 246.An -nosplit 247The 248.Nm pidfile 249functionality is based on ideas from 250.An John-Mark Gurney Aq jmg@FreeBSD.org . 251.Pp 252The code and manual page was written by 253.An Pawel Jakub Dawidek Aq pjd@FreeBSD.org . |