Index: trunk/src/sh_processcheck.c
===================================================================
--- trunk/src/sh_processcheck.c	(revision 397)
+++ trunk/src/sh_processcheck.c	(revision 398)
@@ -864,6 +864,6 @@
 {
   int  cc; 
-  unsigned int  lnum   = 0;
-  unsigned long num    = 0;
+  volatile unsigned int  lnum   = 0;
+  volatile unsigned long num    = 0;
   char c;
   unsigned int  pos = 0;
@@ -907,8 +907,9 @@
 	      char errbuf[SH_ERRBUF_SIZE];
 
-	      /* SH_MUTEX_LOCK(mutex_thread_nolog) is in caller */
+	      SH_MUTEX_LOCK(mutex_thread_nolog);
 	      sh_error_handle(SH_ERR_ALL, FIL__, __LINE__, errno, MSG_E_SUBGEN,
 			      sh_error_message(errno, errbuf, sizeof(errbuf)),
 			      _("sh_processes_readps"));
+	      SH_MUTEX_UNLOCK(mutex_thread_nolog);
 	      break;
 	    }
@@ -930,9 +931,10 @@
 	      if (flag_err_debug == SL_TRUE)
 		{
-		  /* SH_MUTEX_LOCK(mutex_thread_nolog) is in caller */
+		  SH_MUTEX_LOCK(mutex_thread_nolog);
 		  sh_error_handle(SH_ERR_ALL, FIL__, __LINE__, num, 
 				  MSG_E_SUBGEN,
 				  tstr,
 				  _("sh_processes_readps"));
+		  SH_MUTEX_UNLOCK(mutex_thread_nolog);
 		}
 	      /* fprintf(stderr, "<%ld> %s\n", num, tstr); */
@@ -1078,7 +1080,8 @@
   if (status != 0)
     {
-      /* SH_MUTEX_LOCK(mutex_thread_nolog) is in caller */
+      SH_MUTEX_LOCK(mutex_thread_nolog);
       sh_error_handle(SH_ERR_ALL, FIL__, __LINE__, status, MSG_E_SUBGEN, 
 		      _("Could not open pipe"), _("sh_processes_runps"));
+      SH_MUTEX_UNLOCK(mutex_thread_nolog);
       SL_RETURN ((-1), _("sh_processes_runps"));
     }
@@ -1161,7 +1164,6 @@
     }
 
-  SH_MUTEX_LOCK(mutex_thread_nolog);
   retval = sh_processes_runps (res, NULL, 0, SH_PR_PS, 0);
-  SH_MUTEX_UNLOCK(mutex_thread_nolog);
+
   for (i = sh_prochk_minpid; i != sh_prochk_maxpid; ++i)
     {
@@ -1169,7 +1171,6 @@
       res[j] = sh_processes_check ((pid_t) i, res[j]);
     }
-  SH_MUTEX_LOCK(mutex_thread_nolog);
+
   retval += sh_processes_runps (res, NULL, 0, SH_PR_PS2, 0);
-  SH_MUTEX_UNLOCK(mutex_thread_nolog);
 
   if (retval != 0)
