pidfile.3 (7f8d054f8aa98ec4697381bc16e948fa39e436d9) pidfile.3 (cc1ddd46b2c9605ad1f37d20505e3ef86440775a)
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.

--- 136 unchanged lines hidden (view full) ---

145pfh = pidfile_open("/var/run/daemon.pid", 0600, &otherpid);
146if (pfh == NULL) {
147 if (errno == EEXIST) {
148 errx(EXIT_FAILURE, "Daemon already running, pid: %jd.",
149 (intmax_t)otherpid);
150 }
151 /* If we cannot create pidfile from other reasons, only warn. */
152 warn("Cannot open or create pidfile");
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.

--- 136 unchanged lines hidden (view full) ---

145pfh = pidfile_open("/var/run/daemon.pid", 0600, &otherpid);
146if (pfh == NULL) {
147 if (errno == EEXIST) {
148 errx(EXIT_FAILURE, "Daemon already running, pid: %jd.",
149 (intmax_t)otherpid);
150 }
151 /* If we cannot create pidfile from other reasons, only warn. */
152 warn("Cannot open or create pidfile");
153 /*
154 * Eventhough pfh is NULL we can continue, as the other pidfile_*
155 * function can handle such situation by doing nothing except setting
156 * errno to EDOOFUS.
157 */
153}
154
155if (daemon(0, 0) == -1) {
156 warn("Cannot daemonize");
157 pidfile_remove(pfh);
158 exit(EXIT_FAILURE);
159}
160

--- 132 unchanged lines hidden ---
158}
159
160if (daemon(0, 0) == -1) {
161 warn("Cannot daemonize");
162 pidfile_remove(pfh);
163 exit(EXIT_FAILURE);
164}
165

--- 132 unchanged lines hidden ---