Index: trunk/src/samhain.c
===================================================================
--- trunk/src/samhain.c	(revision 143)
+++ trunk/src/samhain.c	(revision 144)
@@ -799,5 +799,6 @@
 static pid_t * procdirSamhain ()
 {
-  pid_t        * pidlist = malloc(sizeof(pid_t) * 65535);
+  volatile pid_t        * pidlist = malloc(sizeof(pid_t) * 65535);
+  pid_t        * dummy;
   struct dirent * d;
   DIR *        dp;
@@ -817,5 +818,6 @@
   if (0 != stat(SH_INSTALL_PATH, &buf))
     {
-      free(pidlist);
+      dummy = pidlist;
+      free(dummy);
       return NULL;
     }
@@ -825,5 +827,6 @@
   if (NULL == (dp = opendir("/proc")))
     {
-      free(pidlist);
+      dummy = pidlist;
+      free(dummy);
       return NULL;
     }
@@ -1193,13 +1196,13 @@
   float         st_1, st_2;
   int           status;
-  long          cct = 0; /* main loop iterations */
-
-  int           flag_check_1 = 0;
-  int           flag_check_2 = 0;
+  volatile long          cct = 0; /* main loop iterations */
+
+  volatile int           flag_check_1 = 0;
+  volatile int           flag_check_2 = 0;
 
   int           check_done   = 0;
 #endif
 
-  time_t        told;
+  volatile time_t        told;
   time_t        tcurrent;
   size_t        tzlen;
Index: trunk/src/sh_cat.c
===================================================================
--- trunk/src/sh_cat.c	(revision 143)
+++ trunk/src/sh_cat.c	(revision 144)
@@ -125,5 +125,5 @@
 
 #ifdef SH_USE_PROCESSCHECK
-  { MSG_PCK_CHECK,   SH_ERR_NOTICE,  RUN,   N_("msg=\"Checking processes in pid interval [%ld,%ld]\"")},
+  { MSG_PCK_CHECK,   SH_ERR_INFO,    RUN,   N_("msg=\"Checking processes in pid interval [%ld,%ld]\"")},
   { MSG_PCK_OK,      SH_ERR_ALL,     RUN,   N_("msg=\"PID %ld found with tests %s\"")},
   { MSG_PCK_P_HIDDEN,SH_ERR_SEVERE,  EVENT, N_("msg=\"POLICY [Process] Hidden pid: %ld tests: %s\" path=\"%s\" userid=\"%s\"")},
@@ -138,5 +138,5 @@
 
 #ifdef SH_USE_MOUNTS
-  { MSG_MNT_CHECK,   SH_ERR_NOTICE,  RUN,   N_("msg=\"Checking mounts\"")},
+  { MSG_MNT_CHECK,   SH_ERR_INFO,    RUN,   N_("msg=\"Checking mounts\"")},
   { MSG_MNT_MEMLIST, SH_ERR_ERR,     RUN,   N_("msg=\"Cannot read mount list from memory\"")},
   { MSG_MNT_MNTMISS, SH_ERR_WARN,    EVENT, N_("msg=\"Mount missing\" path=\"%s\"")},
@@ -440,5 +440,5 @@
 
 #ifdef SH_USE_PROCESSCHECK
-  { MSG_PCK_CHECK,   SH_ERR_NOTICE,  RUN,   N_("msg=<Checking processes in pid interval [%ld,%ld]>")},
+  { MSG_PCK_CHECK,   SH_ERR_INFO,    RUN,   N_("msg=<Checking processes in pid interval [%ld,%ld]>")},
   { MSG_PCK_OK,      SH_ERR_ALL,     RUN,   N_("msg=<PID %ld found with tests %s>")},
   { MSG_PCK_P_HIDDEN,SH_ERR_SEVERE,  EVENT, N_("msg=<POLICY [Process] Hidden pid: %ld tests: %s> path=<%s> userid=<%s>")},
Index: trunk/src/sh_error.c
===================================================================
--- trunk/src/sh_error.c	(revision 143)
+++ trunk/src/sh_error.c	(revision 144)
@@ -20,8 +20,12 @@
 #include "config_xor.h"
 
-/* Required on linux to get the correct strerror_r function. Also
- * for recursive mutexes (_XOPEN_SOURCE >= 500).
- */
+/* Required on Linux to get the correct strerror_r function. Also
+ * for recursive mutexes (_XOPEN_SOURCE >= 500). Gives funny error
+ * on Solaris 10/gcc ('c99' compiler required - huh? Isn't gcc 
+ * good enough?).
+ */
+#if !defined(__sun__) && !defined(__sun)
 #define _XOPEN_SOURCE 600
+#endif
 #include <string.h>
 #include <stdio.h>     
@@ -1318,5 +1322,5 @@
 
  exit_here:
-
+  ; /* label at end of compound statement */
   SH_MUTEX_RECURSIVE_UNLOCK(mutex_err_handle);
 
Index: trunk/src/sh_mem.c
===================================================================
--- trunk/src/sh_mem.c	(revision 143)
+++ trunk/src/sh_mem.c	(revision 144)
@@ -185,4 +185,5 @@
     }
  out:
+  ; /* label at end of compound statement */
   SH_MUTEX_RECURSIVE_UNLOCK(mutex_mem);
   SL_RET0(_("sh_mem_stat"));
@@ -444,4 +445,5 @@
   Mem_Current -= size;
  out:
+  ; /* label at end of compound statement */
   SH_MUTEX_RECURSIVE_UNLOCK(mutex_mem);
   SL_RET0(_("sh_mem_free"));
Index: trunk/src/sh_processcheck.c
===================================================================
--- trunk/src/sh_processcheck.c	(revision 143)
+++ trunk/src/sh_processcheck.c	(revision 144)
@@ -689,6 +689,6 @@
   struct stat buf;
   DIR * dir;
+  int  retval;
 #ifdef HAVE_STATVFS
-  int  retval;
   struct statvfs vfsbuf;
 #endif
@@ -753,5 +753,9 @@
   sl_snprintf (path, sizeof(path), "/proc/%ld", (unsigned long) pid);
 
-  if (0 == retry_lstat (FIL__, __LINE__, path, &buf))
+  do {
+    retval = lstat (path, &buf);
+  } while (retval < 0 && errno == EINTR);
+
+  if (0 == retval)
     { 
       res |= SH_PR_LSTAT;   res |= SH_PR_ANY; ++have_checks;
@@ -782,5 +786,7 @@
     {
       res |= SH_PR_CHDIR;   res |= SH_PR_ANY; ++have_checks;
-      retry_aud_chdir(FIL__, __LINE__, "/");
+      do {
+	retval = chdir ("/");
+      } while (retval < 0 && errno == EINTR);
     }
   ++need_checks;
@@ -1215,5 +1221,6 @@
     return SH_MOD_FAILED;
 #ifdef HAVE_PTHREAD
-  if (arg != NULL && arg->initval < 0 && sh.flag.isdaemon == S_TRUE)
+  if (arg != NULL && arg->initval < 0 &&
+      (sh.flag.isdaemon == S_TRUE || sh.flag.loop == S_TRUE))
     {
       if (0 == sh_pthread_create(sh_threaded_module_run, (void *)arg))
@@ -1307,5 +1314,5 @@
   userdef_maxpid     = 0;
   sh_prochk_maxpid   = 0x8000;
-  sh_prochk_minpid   = 0x0000;
+  sh_prochk_minpid   = 0x0001;
   sh_prochk_interval = SH_PROCHK_INTERVAL;
 
Index: trunk/src/sh_utmp.c
===================================================================
--- trunk/src/sh_utmp.c	(revision 143)
+++ trunk/src/sh_utmp.c	(revision 144)
@@ -495,5 +495,6 @@
     return SH_MOD_FAILED;
 #ifdef HAVE_PTHREAD
-  if (arg != NULL && arg->initval < 0 && sh.flag.isdaemon == S_TRUE)
+  if (arg != NULL && arg->initval < 0 && 
+      (sh.flag.isdaemon == S_TRUE || sh.flag.loop == S_TRUE))
     {
       if (0 == sh_pthread_create(sh_threaded_module_run, (void *)arg))
Index: trunk/src/slib.c
===================================================================
--- trunk/src/slib.c	(revision 143)
+++ trunk/src/slib.c	(revision 144)
@@ -55,4 +55,5 @@
 #define SH_NEED_PWD_GRP 1
 #include "sh_static.h"
+#include "sh_pthread.h"
 
 #undef  FIL__
@@ -1514,4 +1515,5 @@
 static SL_OFILE * ofiles[MAXFD]; 
 
+SH_MUTEX_STATIC(mutex_ticket, PTHREAD_MUTEX_INITIALIZER);
 
 static unsigned int nonce_counter = TOFFSET;
@@ -1522,9 +1524,10 @@
   unsigned int high; /* index */ 
   unsigned int low;  /* nonce */
+  SL_TICKET    retval = SL_EINTERNAL;
 
   SL_ENTER(_("sl_create_ticket"));
 
-  if (myindex >= MAXFD) 
-    SL_IRETURN (SL_EINTERNAL, _("sl_create_ticket")); 
+  if (myindex >= MAXFD)
+    goto out_ticket;
 
   /* mask out the high bit and check that it is not used
@@ -1534,5 +1537,7 @@
 
   if (high != myindex + TOFFSET) 
-    SL_IRETURN (SL_EINTERNAL, _("sl_create_ticket")); 
+    goto out_ticket;
+
+  SH_MUTEX_LOCK_UNSAFE(mutex_ticket);
 
   low = nonce_counter & 0xffff;
@@ -1541,5 +1546,5 @@
    */
   if ((low != nonce_counter++) || low == 0)
-    SL_IRETURN (SL_EINTERNAL, _("sl_create_ticket"));
+    goto out_ticket;
  
   /* Wrap around the nonce counter.
@@ -1549,5 +1554,11 @@
     nonce_counter = TOFFSET;
 
-  SL_RETURN ((SL_TICKET) ((high << 16) | low), _("sl_create_ticket")); 
+  retval = (SL_TICKET) ((high << 16) | low);
+
+ out_ticket:
+  ;
+
+  SH_MUTEX_UNLOCK_UNSAFE(mutex_ticket);
+  SL_RETURN (retval, _("sl_create_ticket")); 
 }
 
