--- openntpd-3.9p1.old/ntpd.c	2006-05-14 06:29:23.000000000 +0100
+++ openntpd-3.9p1/ntpd.c	2006-09-19 11:54:13.000000000 +0100
@@ -149,6 +149,15 @@
 	if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pipe_chld) == -1)
 		fatal("socketpair");
 
+	if (!conf.debug)
+	{
+		FILE *pidfile = fopen("/var/run/ntpd.pid", "w");
+		if (pidfile) {
+			fprintf(pidfile, "%d\n", getpid());
+			fclose(pidfile);
+		}
+	}
+	
 	/* fork child process */
 	chld_pid = ntp_main(pipe_chld, &conf);
 
@@ -215,6 +224,9 @@
 	if (chld_pid)
 		kill(chld_pid, SIGTERM);
 
+	if (!conf.debug)
+		unlink("/var/run/ntpd.pid");
+
 	do {
 		if ((pid = wait(NULL)) == -1 &&
 		    errno != EINTR && errno != ECHILD)
