Index: configure
--- configure.orig	2009-04-15 20:21:29 +0200
+++ configure	2009-04-16 21:42:35 +0200
@@ -4572,6 +4572,7 @@
 
 
 for ac_header in  \
+	sys/types.h \
         alloca.h \
 	arpa/inet.h \
 	asm/page.h \
Index: file.c
--- file.c.orig	2009-02-13 14:06:31 +0100
+++ file.c	2009-04-16 21:43:43 +0200
@@ -115,6 +115,9 @@
 
   /* Set the location of monit's state file */
   if(Run.statefile == NULL) {
+    if(!getuid())
+        snprintf(buf, STRLEN, "%s/%s", MYSTATEDIR, MYSTATEFILE);
+    else
     snprintf(buf, STRLEN, "%s/.%s", Run.Env.home, MYSTATEFILE);
     Run.statefile= xstrdup(buf);
   }
@@ -186,17 +189,7 @@
     return (rcfile);
   }
   memset(rcfile, 0, STRLEN);
-  snprintf(rcfile, STRLEN, "/etc/%s", MONITRC);
-  if(File_exist(rcfile)) {
-    return (rcfile);
-  }
-  memset(rcfile, 0, STRLEN);
-  snprintf(rcfile, STRLEN, "%s/%s", SYSCONFDIR, MONITRC);
-  if(File_exist(rcfile)) {
-    return (rcfile);
-  }
-  memset(rcfile, 0, STRLEN);
-  snprintf(rcfile, STRLEN, "/usr/local/etc/%s", MONITRC);
+  snprintf(rcfile, STRLEN, "@l_prefix@/etc/monit/%s", MONITRC);
   if(File_exist(rcfile)) {
     return (rcfile);
   }
@@ -206,8 +199,8 @@
     return (rcfile);
   }
   LogError("%s: Cannot find the control file at "
-      "~/.%s, /etc/%s, %s/%s, /usr/local/etc/%s or at ./%s \n",
-      prog, MONITRC, MONITRC, SYSCONFDIR, MONITRC, MONITRC, MONITRC);
+      "~/.%s, @l_prefix@/etc/monit/%s, or at ./%s \n",
+      prog, MONITRC, MONITRC, MONITRC);
   exit(1);
   
 }
Index: monit.1
--- monit.1.orig	2009-04-15 20:21:25 +0200
+++ monit.1	2009-04-16 21:42:35 +0200
@@ -3662,9 +3662,9 @@
 \&\fI~/.monitrc\fR  
    Default run control file
 .PP
-\&\fI/etc/monitrc\fR
+\&\fI@l_prefix@/etc/monit/monitrc\fR
    If the control file is not found in the default 
-   location and /etc contains a \fImonitrc\fR file, this
+   location and @l_prefix@/etc/monit contains a \fImonitrc\fR file, this
    file will be used instead.
 .PP
 \&\fI./monitrc\fR  
@@ -3677,14 +3677,10 @@
    Lock file to help prevent concurrent runs (non-root
    mode).
 .PP
-\&\fI/var/run/monit.pid\fR
+\&\fI@l_prefix@/var/monit/monit.pid\fR
    Lock file to help prevent concurrent runs (root mode,
    Linux systems).
 .PP
-\&\fI/etc/monit.pid\fR
-   Lock file to help prevent concurrent runs (root mode,
-   systems without /var/run).
-.PP
 \&\fI~/.monit.state\fR  
    Monit save its state to this file and utilize 
    information found in this file to recover from 
Index: monitor.h
--- monitor.h.orig	2009-04-12 10:16:37 +0200
+++ monitor.h	2009-04-16 21:42:35 +0200
@@ -102,6 +102,7 @@
 #define MYPIDMASK          0122
 #define MYPIDDIR           PIDDIR
 #define MYPIDFILE          "monit.pid"
+#define MYSTATEDIR         PIDDIR
 #define MYSTATEFILE        "monit.state"
 #define MYIDFILE           "monit.id"
 #define MYEVENTLISTBASE    "/var/monit"
Index: process/sysdep_LINUX.c
--- process/sysdep_LINUX.c.orig	2009-02-28 21:56:48 +0100
+++ process/sysdep_LINUX.c	2009-04-16 21:42:35 +0200
@@ -88,6 +88,8 @@
 # define HZ sysconf(_SC_CLK_TCK)
 #endif
 
+#include <errno.h>
+
 #include "monitor.h"
 #include "process.h"
 #include "process_sysdep.h"
