Index: ChangeLog
===================================================================
--- ChangeLog	(revision 27c3a933fbd4f5aae07ffa61ec255a5b783ddb73)
+++ ChangeLog	(revision 2a2bb60634595a267b3fcf2e2013d2190eb477d5)
@@ -1,4 +1,10 @@
 $Id$
 
+2.0.9-pre-3
+	Added testing feature for capturing stderr messages
+	        from commands and displaying them in the errors buffer.
+		This feature is disabled by default.
+		Enable in owl.h with:  OWL_STDERR_REDIR 1
+	
 2.0.9-pre-2
 	Better reporting of perl errors (both into the errqueue
Index: functions.c
===================================================================
--- functions.c	(revision ec6ff526f80f4544b68f01e84ccd88c783e54326)
+++ functions.c	(revision 2a2bb60634595a267b3fcf2e2013d2190eb477d5)
@@ -1972,4 +1972,8 @@
   FILE *p;
 
+#if OWL_STDERR_REDIR
+  redirect = " < /dev/null";
+#endif 
+
   if (argc<2) {
     owl_function_error("Wrong number of arguments to the exec command");
Index: owl.c
===================================================================
--- owl.c	(revision 27c3a933fbd4f5aae07ffa61ec255a5b783ddb73)
+++ owl.c	(revision 2a2bb60634595a267b3fcf2e2013d2190eb477d5)
@@ -21,4 +21,10 @@
 #include <sys/stat.h>
 #include "owl.h"
+
+#if OWL_STDERR_REDIR
+#include <sys/ioctl.h>
+int stderr_replace(void);
+void stderr_redirect(int rfd);
+#endif
 
 static const char fileIdent[] = "$Id$";
@@ -42,4 +48,7 @@
   ZNotice_t notice;
 #endif
+#if OWL_STDERR_REDIR
+  int newstderr;
+#endif
 
   argcsave=argc;
@@ -136,4 +145,10 @@
 #endif
   owl_global_set_haveaim(&g);
+
+#if OWL_STDERR_REDIR
+  /* Do this only after we've started curses up... */  
+  newstderr = stderr_replace();
+#endif   
+
   
   /* create the owl directory, in case it does not exist */
@@ -530,4 +545,9 @@
       owl_function_makemsg("Unable to handle keypress");
     }
+
+#if OWL_STDERR_REDIR
+    stderr_redirect(newstderr);
+#endif   
+
   }
 }
@@ -552,2 +572,47 @@
   fprintf(stderr, "  -t      set the tty name\n");
 }
+
+
+
+#if OWL_STDERR_REDIR
+
+/* Replaces stderr with a pipe so that we can read from it. 
+ * Returns the fd of the pipe from which stderr can be read. */
+int stderr_replace(void) {
+  int pipefds[2];
+  if (0 != pipe(pipefds)) {
+    perror("pipe");
+    owl_function_debugmsg("stderr_replace: pipe FAILED\n");
+    return -1;
+  }
+    owl_function_debugmsg("stderr_replace: pipe: %d,%d\n", pipefds[0], pipefds[1]);
+  if (-1 == dup2(pipefds[1], 2 /*stderr*/)) {
+    owl_function_debugmsg("stderr_replace: dup2 FAILED (%s)\n", strerror(errno));
+    perror("dup2");
+    return -1;
+  }
+  return pipefds[0];
+}
+
+/* Sends stderr (read from rfd) messages to a file */
+void stderr_redirect(int rfd) {
+  int navail, bread;
+  char *buf;
+  /*owl_function_debugmsg("stderr_redirect: called with rfd=%d\n", rfd);*/
+  if (rfd<0) return;
+  if (-1 == ioctl(rfd, FIONREAD, (void*)&navail)) {
+    return;
+  }
+  /*owl_function_debugmsg("stderr_redirect: navail = %d\n", navail);*/
+  if (navail<=0) return;
+  if (navail>256) { navail = 256; }
+  buf = owl_malloc(navail+1);
+  bread = read(rfd, buf, navail);
+  if (buf[navail-1] != '\0') {
+    buf[navail] = '\0';
+  }
+  owl_function_error("Err: %s", buf);
+  owl_free(buf);
+}
+
+#endif /* OWL_STDERR_REDIR */
Index: owl.h
===================================================================
--- owl.h	(revision 27c3a933fbd4f5aae07ffa61ec255a5b783ddb73)
+++ owl.h	(revision 2a2bb60634595a267b3fcf2e2013d2190eb477d5)
@@ -17,10 +17,12 @@
 #endif
 
-
-
 static const char owl_h_fileIdent[] = "$Id$";
 
-#define OWL_VERSION         2.0.9-pre-2
-#define OWL_VERSION_STRING "2.0.9-pre-2"
+#define OWL_VERSION         2.0.9-pre-3
+#define OWL_VERSION_STRING "2.0.9-pre-3"
+
+/* Feature that is being tested to redirect stderr through a pipe. 
+ * There may still be some portability problems with this. */
+#define OWL_STDERR_REDIR 1
 
 #define OWL_DEBUG 0
Index: zwrite.c
===================================================================
--- zwrite.c	(revision 836ea3a33ae3b7678a5e6a78b57dd7c33e014f8f)
+++ zwrite.c	(revision 2a2bb60634595a267b3fcf2e2013d2190eb477d5)
@@ -154,5 +154,7 @@
       openline=owl_malloc(strlen(zsigproc)+40);
       strcpy(openline, zsigproc);
+#if !(OWL_STDERR_REDIR)
       strcat(openline, " 2> /dev/null");
+#endif
       file=popen(openline, "r");
       owl_free(openline);
