summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2006-01-28 14:13:15 +0000
committerpjd <pjd@FreeBSD.org>2006-01-28 14:13:15 +0000
commitb5f41824aea547806b01c1a5b61d0b22734c9487 (patch)
tree0fd8b0e295c81a34c9cf494135b2c7307f52444f /lib
parent9a16f30d45c8da78e23c641fc8178353523ab33b (diff)
downloadFreeBSD-src-b5f41824aea547806b01c1a5b61d0b22734c9487.zip
FreeBSD-src-b5f41824aea547806b01c1a5b61d0b22734c9487.tar.gz
- Add a note that passing NULL to pidfile_write(), pidfile_remove() and
pidfile_close() functions is safe. This possibility is used in example code. - Cast pid_t to int. Requested by: yar
Diffstat (limited to 'lib')
-rw-r--r--lib/libutil/pidfile.316
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/libutil/pidfile.3 b/lib/libutil/pidfile.3
index f04522d..4895975 100644
--- a/lib/libutil/pidfile.3
+++ b/lib/libutil/pidfile.3
@@ -105,14 +105,24 @@ will be set.
.Rv -std pidfile_write pidfile_close pidfile_remove
.Sh EXAMPLES
The following example shows in which order these functions should be used.
+Note that it is safe to pass
+.Dv NULL
+to
+.Fn pidfile_write ,
+.Fn pidfile_remove
+and
+.Fn pidfile_close
+functions.
.Bd -literal
struct pidfh *pfh;
pid_t otherpid, childpid;
pfh = pidfile_open("/var/run/daemon.pid", 0600, &otherpid);
if (pfh == NULL) {
- if (errno == EEXIST)
- errx(EXIT_FAILURE, "Daemon already running, pid: %d.", otherpid);
+ if (errno == EEXIST) {
+ errx(EXIT_FAILURE, "Daemon already running, pid: %d.",
+ (int)otherpid);
+ }
/* If we cannot create pidfile from other reasons, only warn. */
warn("Cannot open or create pidfile");
}
@@ -137,7 +147,7 @@ for (;;) {
/* Do child work. */
break;
default:
- syslog(LOG_INFO, "Child %d started.", childpid);
+ syslog(LOG_INFO, "Child %d started.", (int)childpid);
break;
}
}
OpenPOWER on IntegriCloud