Index: luci2/zhttpd/zhttpd.c
===================================================================
--- luci2/zhttpd/zhttpd.c	(revision 5793)
+++ luci2/zhttpd/zhttpd.c	(revision 5830)
@@ -3,4 +3,5 @@
 #include <string.h>
 #include <unistd.h>
+#include <stdio.h>
 #include <sys/epoll.h>
 #include <sys/types.h>
@@ -15,5 +16,7 @@
 
 static void daemonize() {
-	switch (fork()) {
+	pid_t pid;
+	FILE *fp;
+	switch ((pid = fork())) {
 		case -1:
 			exit(1);
@@ -21,4 +24,9 @@
 			break;
 		default:
+			fp = fopen(zhttpd.pidfile, "w");
+			if (fp) {
+				fprintf(fp, "%i\n", (int)pid);
+				fclose(fp);
+			}
 			exit(0);
 	}
@@ -85,4 +93,5 @@
 	sigaction(SIGPIPE, &action, NULL);
 
+	zhttpd.pidfile = "/var/run/zhttpd.pid";
 	int firstrun = 1;
 	do {
