summaryrefslogtreecommitdiff
path: root/libexec
diff options
context:
space:
mode:
authorcvs2svn <cvs2svn@FreeBSD.org>2006-09-02 09:56:29 +0000
committercvs2svn <cvs2svn@FreeBSD.org>2006-09-02 09:56:29 +0000
commit7cb45b973ac29b7aad4a96f25ea5db82ae107488 (patch)
tree2a7a88f96d53beb47b04df0c83e564fb4414a5fb /libexec
parent7d00ca6a9c4e7f5c8ea35af72a9d26f0d3765bc8 (diff)
Notes
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 000000000000..23dbe38be9cc
--- /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;
+}