Index: trunk/src/sh_modules.c
===================================================================
--- trunk/src/sh_modules.c	(revision 258)
+++ trunk/src/sh_modules.c	(revision 259)
@@ -23,4 +23,5 @@
     N_("UTMP"),
     -1,
+    SH_MODFL_NOTIMER,
     sh_utmp_init,
     sh_utmp_timer,
@@ -39,4 +40,5 @@
     N_("MOUNTS"),
     -1,
+    0,
     sh_mounts_init,
     sh_mounts_timer,
@@ -55,4 +57,5 @@
     N_("USERFILES"),
     -1,
+    0,
     sh_userfiles_init,
     sh_userfiles_timer,
@@ -71,4 +74,5 @@
     N_("KERNEL"),
     -1,
+    0,
     sh_kern_init,
     sh_kern_timer,
@@ -87,4 +91,5 @@
     N_("SUIDCHECK"),
     -1,
+    0,
     sh_suidchk_init,
     sh_suidchk_timer,
@@ -103,4 +108,5 @@
     N_("PROCESSCHECK"),
     -1,
+    0,
     sh_prochk_init,
     sh_prochk_timer,
@@ -119,4 +125,5 @@
     N_("PORTCHECK"),
     -1,
+    0,
     sh_portchk_init,
     sh_portchk_timer,
@@ -135,4 +142,5 @@
     N_("LOGMON"),
     -1,
+    0,
     sh_log_check_init,
     sh_log_check_timer,
@@ -150,4 +158,5 @@
     NULL,
     -1,
+    0,
 
     NULL,
Index: trunk/src/sh_pthread.c
===================================================================
--- trunk/src/sh_pthread.c	(revision 258)
+++ trunk/src/sh_pthread.c	(revision 259)
@@ -182,5 +182,6 @@
 		  pthread_testcancel();
 		}
-	      retry_msleep(1,0);
+	      if (0 == (SH_MODFL_NOTIMER & this_module->flags))
+		retry_msleep(1,0);
 	    }
 
Index: trunk/src/sh_utmp.c
===================================================================
--- trunk/src/sh_utmp.c	(revision 258)
+++ trunk/src/sh_utmp.c	(revision 259)
@@ -80,4 +80,5 @@
 #include "sh_utmp.h"
 #include "sh_pthread.h"
+#include "sh_inotify.h"
 
 SH_MUTEX_EXTERN(mutex_thread_nolog);
@@ -186,4 +187,6 @@
 static char   terminated_line[UT_HOSTSIZE]; 
 #endif
+
+static char * mode_path[] = { _PATH_WTMP, _PATH_WTMP, _PATH_UTMP };
 
 static struct SH_UTMP_S save_utmp;
@@ -519,4 +522,8 @@
 #endif
 
+#if defined(HAVE_PTHREAD)
+static sh_watches inotify_watch;
+#endif
+
 int sh_utmp_end ()
 {
@@ -540,10 +547,15 @@
   set_defaults();
   init_done          = 0;
+
+  sh_inotify_remove(&inotify_watch);
+
   SL_RETURN( (0), _("sh_utmp_end"));
 }
 
+
 int sh_utmp_reconf()
 {
   set_defaults();
+  sh_inotify_remove(&inotify_watch);
   return 0;
 }
@@ -557,4 +569,7 @@
 int sh_utmp_timer (time_t tcurrent)
 {
+#if !defined(HAVE_PTHREAD)
+  retry_msleep(1, 0);
+
   if ((time_t) (tcurrent - lastcheck) >= ShUtmpInterval)
     {
@@ -563,4 +578,25 @@
     }
   return 0;
+#else
+  int errnum = 0;
+  
+  if (sh.flag.checkSum != SH_CHECK_INIT)
+    sh_inotify_wait_for_change(mode_path[1], &inotify_watch, 
+			       &errnum, ShUtmpInterval);
+
+  lastcheck  = tcurrent;
+  if (SH_INOTIFY_ERROR(errnum))
+    {
+      char ebuf[SH_ERRBUF_SIZE];
+
+      SH_MUTEX_LOCK(mutex_thread_nolog);
+      sh_error_message(errnum, ebuf, sizeof(ebuf));
+      sh_error_handle (SH_ERR_WARN, FIL__, __LINE__, errnum, MSG_E_SUBGEN,
+		       ebuf,
+		       _("sh_utmp_timer") );
+      SH_MUTEX_UNLOCK(mutex_thread_nolog);    
+    }
+  return -1;
+#endif
 }
 
@@ -574,5 +610,10 @@
   SL_ENTER(_("sh_utmp_check"));
   if (ShUtmpActive == BAD)
-    SL_RETURN( (-1), _("sh_utmp_check"));
+    {
+#if defined(HAVE_PTHREAD)
+      sh_inotify_remove(&inotify_watch);
+#endif
+      SL_RETURN( (-1), _("sh_utmp_check"));
+    }
   SH_MUTEX_LOCK(mutex_thread_nolog);
   sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_UT_CHECK);
@@ -746,23 +787,19 @@
  *    - link user.ut_record   -> log_record
  */
+
 #ifdef HAVE_UTTYPE  
 static int sh_utmp_is_virtual (char * in_utline, char * in_uthost)
 {
-  if (in_utline != NULL)
-    {
-      if (0 == sl_strncmp(in_utline, _("ttyp"), 4))
-	{ return 0; }
-      else if (0 == sl_strncmp(in_utline, _("ttyq"), 4))
-	{ return 0; }
-    }
-  if (in_uthost != NULL   && 
+
+  if (in_uthost != NULL   &&
+      in_utline != NULL   &&
       in_uthost[0] == ':' && 
       in_uthost[1] == '0' && 
-      in_uthost[2] == '\0')
-    {
-      /* return 0; */
-      return 1;  /* actually does not seem portable, not even among linuxes */
-    }
-  return 1;
+      0 == sl_strncmp(in_utline, _("pts/"), 4))
+    {
+      return 1;
+    }
+
+  return 0;
 }
 #endif
@@ -884,5 +921,5 @@
 	SH_MUTEX_UNLOCK(mutex_thread_nolog);
       } else
-	if (0 != sh_utmp_is_virtual(ut->ut_line, (char*)user->ut_host))
+	if (0 == sh_utmp_is_virtual(ut->ut_line, (char*)user->ut_host))
 	  {       
 	    status = sh_utmp_login_a((char*)user->name);
@@ -923,33 +960,39 @@
       if (user != NULL)
 	{
-	  status = sh_utmp_login_r((char*)user->name);
-	  SH_MUTEX_LOCK(mutex_thread_nolog);
-	  (void) sh_unix_time (ut->ut_time, ttt, TIM_MAX);
-	  sh_error_handle( ShUtmpLogout, FIL__, __LINE__, 0,
+#if defined(__linux__)
+	  if (0 == sh_utmp_is_virtual(ut->ut_line, (char*)user->ut_host)) {
+#endif
+	    status = sh_utmp_login_r((char*)user->name);
+	    SH_MUTEX_LOCK(mutex_thread_nolog);
+	    (void) sh_unix_time (ut->ut_time, ttt, TIM_MAX);
+	    sh_error_handle( ShUtmpLogout, FIL__, __LINE__, 0,
 #if defined(HAVE_UTHOST) && defined(HAVE_UTADDR)
-			   MSG_UT_LG3X,
+			     MSG_UT_LG3X,
 #elif defined(HAVE_UTHOST)
-			   MSG_UT_LG3A,
-#else
-			   MSG_UT_LG3B,
-#endif
-			   user->name,
-			   user->ut_tty,
+			     MSG_UT_LG3A,
+#else
+			     MSG_UT_LG3B,
+#endif
+			     user->name,
+			     user->ut_tty,
 #if defined(HAVE_UTHOST) && defined(HAVE_UTADDR)
-			   user->ut_host,
-			   user->ut_ship,
+			     user->ut_host,
+			     user->ut_ship,
 #elif defined(HAVE_UTHOST)
-			   user->ut_host,
-#endif
-			   ttt,
-			   status
-			   );
-	  SH_MUTEX_UNLOCK(mutex_thread_nolog);
-	  userold->next = user->next;
-	  if (user == userlist)
-	    userlist = user->next;
-	  sh_utmp_logout_morechecks((struct log_user *)user);
-	  SH_FREE((struct log_user *)user);
-	  user = NULL;
+			     user->ut_host,
+#endif
+			     ttt,
+			     status
+			     );
+	    SH_MUTEX_UNLOCK(mutex_thread_nolog);
+	    userold->next = user->next;
+	    if (user == userlist)
+	      userlist = user->next;
+	    sh_utmp_logout_morechecks((struct log_user *)user);
+	    SH_FREE((struct log_user *)user);
+	    user = NULL;
+#if defined(__linux__)
+	  }
+#endif
 	}
       else
@@ -1053,6 +1096,4 @@
 static unsigned long lastread = 0;
 
-static char * mode_path[] = { _PATH_WTMP, _PATH_WTMP, _PATH_UTMP };
-
 static void sh_utmp_check_internal (int mode)
 {
