Index: /trunk/docs/Changelog
===================================================================
--- /trunk/docs/Changelog	(revision 270)
+++ /trunk/docs/Changelog	(revision 271)
@@ -1,3 +1,5 @@
 2.6.2:
+	* handle named pipes in log monitoring module
+	  (open in nonblocking mode, ignore read error if empty)
 	* fix bug in the server function to probe for necessity
 	  of configuration reload for client
Index: /trunk/include/sh_log_check.h
===================================================================
--- /trunk/include/sh_log_check.h	(revision 270)
+++ /trunk/include/sh_log_check.h	(revision 271)
@@ -25,4 +25,5 @@
 #define SH_LOGFILE_MOVED  (1<<0)
 #define SH_LOGFILE_REWIND (1<<1)
+#define SH_LOGFILE_PIPE   (1<<2)
 
 struct sh_logfile 
Index: /trunk/src/sh_log_check.c
===================================================================
--- /trunk/src/sh_log_check.c	(revision 270)
+++ /trunk/src/sh_log_check.c	(revision 271)
@@ -7,4 +7,13 @@
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <fcntl.h>
+
+#if !defined(O_NONBLOCK)
+#if defined(O_NDELAY)
+#define O_NONBLOCK  O_NDELAY
+#else
+#define O_NONBLOCK  0
+#endif
+#endif
 
 #ifdef USE_LOGFILE_MONITOR
@@ -316,11 +325,42 @@
   if (0 == stat(thisfile->filename, &buf))
     {
-      thisfile->inode     = buf.st_ino;
-      thisfile->device_id = buf.st_dev;
+      if (S_ISREG(buf.st_mode)
+#ifdef S_ISLNK
+	  || S_ISLNK(buf.st_mode)
+#endif 
+	  )
+	{
+	  thisfile->inode     = buf.st_ino;
+	  thisfile->device_id = buf.st_dev;
+	  
+	  if (0 != read_pos(thisfile))
+	    {
+	      thisfile->flags &= ~SH_LOGFILE_REWIND;
+	    }
+	}
+      else if (S_ISFIFO(buf.st_mode))
+	{
+	  thisfile->inode      = buf.st_ino;
+	  thisfile->device_id  = buf.st_dev;
+	  thisfile->flags     |= SH_LOGFILE_PIPE;
+	}
+    }
+  else
+    {
+      sh_string * msg =  sh_string_new(0);
+      sh_string_add_from_char(msg, _("Logfile is not a regular file, link, or named pipe: "));
+      sh_string_add_from_char(msg, splits[1]);
       
-      if (0 != read_pos(thisfile))
-	{
-	  thisfile->flags &= ~SH_LOGFILE_REWIND;
-	}
+      SH_MUTEX_LOCK(mutex_thread_nolog);
+      sh_error_handle(SH_ERR_ERR, FIL__, __LINE__, 0, MSG_E_SUBGEN,
+		      sh_string_str(msg),
+		      _("sh_add_watch"));
+      SH_MUTEX_UNLOCK(mutex_thread_nolog);
+      sh_string_destroy(&msg);
+      
+      SH_FREE(filename);
+      SH_FREE(thisfile);
+      SH_FREE(new);
+      return -1;
     }
 
@@ -340,5 +380,8 @@
       sh_watched_logs = thisfile->next;
 
-      save_pos(thisfile);
+      if ((thisfile->flags & SH_LOGFILE_PIPE) == 0)
+	{
+	  save_pos(thisfile);
+	}
 
       if (thisfile->fp)
@@ -360,5 +403,4 @@
 void sh_check_watches()
 {
-  static size_t      count = 0;
   struct sh_logrecord * logrecord;
   struct sh_logfile * thisfile = sh_watched_logs;
@@ -373,4 +415,6 @@
   while (thisfile)
     {
+      volatile size_t count = 0;
+
       SH_MUTEX_LOCK(mutex_thread_nolog);
       tmp = sh_util_safe_name (thisfile->filename);
@@ -529,5 +573,7 @@
   /* detect and handle logfile rotation
    */
-  if (logfile->inode != buf.st_ino && logfile->inode != 0)
+  if (logfile->inode != buf.st_ino && 
+      logfile->inode != 0 &&
+      !S_ISFIFO(buf.st_mode))
     {
       /* Case 1) We have dealt with the moved file already.
@@ -572,5 +618,18 @@
   /* open file
    */
-  logfile->fp = fopen(filename->str, "r");
+  if (!S_ISFIFO(buf.st_mode))
+    {
+      logfile->fp = fopen(filename->str, "r");
+    }
+  else
+    {
+      int fd_temp = open (filename->str, O_RDONLY|O_NONBLOCK);
+
+      if (fd_temp >= 0)
+	{
+	  logfile->fp = fdopen(fd_temp, "r");
+	}
+    }
+
   if (!logfile->fp)
     {
@@ -590,18 +649,21 @@
   sh_string_destroy(&filename);
   
-  if ((logfile->flags & SH_LOGFILE_REWIND) != 0)
-    {
-      rewind(logfile->fp);
-      fgetpos(logfile->fp, &(logfile->offset));
-      logfile->flags &= ~SH_LOGFILE_REWIND;
-    }
-  else
-    {
-      /* file too short
-       */
-      if (0 != fsetpos(logfile->fp, &(logfile->offset)))
+  if ((logfile->flags & SH_LOGFILE_PIPE) == 0)
+    {
+      if ((logfile->flags & SH_LOGFILE_REWIND) != 0)
 	{
 	  rewind(logfile->fp);
 	  fgetpos(logfile->fp, &(logfile->offset));
+	  logfile->flags &= ~SH_LOGFILE_REWIND;
+	}
+      else
+	{
+	  /* file too short
+	   */
+	  if (0 != fsetpos(logfile->fp, &(logfile->offset)))
+	    {
+	      rewind(logfile->fp);
+	      fgetpos(logfile->fp, &(logfile->offset));
+	    }
 	}
     }
@@ -631,5 +693,5 @@
 	  logfile->fp = NULL;
 	  sh_string_destroy(&s);
-	  if (status == 0)
+	  if (status == 0 || (logfile->flags & SH_LOGFILE_PIPE) != 0)
 	    {
 	      return NULL;
@@ -707,5 +769,5 @@
 	  logfile->fp = NULL;
 	  sh_string_destroy(&s);
-	  if (status == 0)
+	  if (status == 0 || (logfile->flags & SH_LOGFILE_PIPE) != 0)
 	    {
 	      return NULL;
@@ -747,5 +809,5 @@
       if (status != 1)
 	{
-	  if (ferror(logfile->fp))
+	  if (ferror(logfile->fp) && (logfile->flags & SH_LOGFILE_PIPE) == 0)
 	    {
 	      char * tmp;
