summaryrefslogtreecommitdiffstats
path: root/libexec
diff options
context:
space:
mode:
authorobrien <obrien@FreeBSD.org>2006-08-31 16:57:46 +0000
committerobrien <obrien@FreeBSD.org>2006-08-31 16:57:46 +0000
commitaeae00d8be62bcd2db4e444c2e5d542bde9e6763 (patch)
tree660624995692b5cbef445c80ec7154db63cc90e4 /libexec
parenta1d5a9ece322c34a4a74809f5b6763bebd2eb3a0 (diff)
downloadFreeBSD-src-aeae00d8be62bcd2db4e444c2e5d542bde9e6763.zip
FreeBSD-src-aeae00d8be62bcd2db4e444c2e5d542bde9e6763.tar.gz
FreeBSD doesn't have the simple pidfile(3), so craft it using FreeBSD's
primitives.
Diffstat (limited to 'libexec')
-rw-r--r--libexec/lukemftpd/nbsd_pidfile.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/libexec/lukemftpd/nbsd_pidfile.h b/libexec/lukemftpd/nbsd_pidfile.h
new file mode 100644
index 0000000..23dbe38
--- /dev/null
+++ b/libexec/lukemftpd/nbsd_pidfile.h
@@ -0,0 +1,30 @@
+/* $FreeBSD$ */
+
+#include <sys/stdint.h>
+#include <sysexits.h>
+
+static int
+pidfile(const char *basename)
+{
+ struct pidfh *pfh;
+ pid_t otherpid, childpid;
+
+ if (basename != NULL) {
+ errx(EX_USAGE, "Need to impliment NetBSD semantics.");
+ }
+
+ pfh = pidfile_open(basename, 0644, &otherpid);
+ if (pfh == NULL) {
+ if (errno == EEXIST) {
+ errx(EXIT_FAILURE, "Daemon already running, pid: %jd.",
+ (intmax_t)otherpid);
+ }
+ /* If we cannot create pidfile from other reasons, only warn. */
+ warn("Cannot open or create pidfile");
+ return -1;
+ }
+
+ pidfile_write(pfh);
+ pidfile_close(pfh);
+ return 0;
+}
OpenPOWER on IntegriCloud