--- pan.c.orig	2006-05-17 15:21:42.000000000 +0200
+++ pan.c	2006-05-17 22:51:35.000000000 +0200
@@ -120,6 +120,7 @@
 
 static char *panname = NULL;
 static char *test_out_dir = NULL;	/* dir to buffer output to */
+static char *ctc_out_dir = NULL;	/* dir to buffer output to */
 zoo_t zoofile;
 static char *reporttype = NULL;
 
@@ -138,6 +139,11 @@
 #define	Dstart		0x000002	/* started command */
 #define Dwait		0x000001	/* wait interrupted */
 
+#define CTC_COVERAGE "/dev/ctc_coverage"
+static char ctc_coverage_cmd[PATH_MAX] = "";
+
+
+
 int
 main(int argc, char **argv)
 {
@@ -254,6 +260,16 @@
 	}
     }
 
+    if (test_out_dir == NULL) {
+      if (getenv("LTPROOT")) {
+	ctc_out_dir = strdup(getenv("LTPROOT"));
+      } else {
+	ctc_out_dir = strdup(get_current_dir_name());
+      }
+    } else {
+      ctc_out_dir = test_out_dir;
+    }
+
     if (panname == NULL) {
 	fprintf(stderr, "pan: Must supply -n\n");
 	exit(1);
@@ -466,6 +482,7 @@
 	    if (sequential)
 		if (++c >= coll->cnt)
 		    c = 0;
+	    sprintf(ctc_coverage_cmd, "/bin/cat %s | /bin/gzip > %s/%s.MON.txt.gz", CTC_COVERAGE, ctc_out_dir, coll->ary[c]->name); system(ctc_coverage_cmd);
 
 	} /* while( (num_active < keep_active) && (starts != 0) ) */
 
@@ -812,6 +829,8 @@
 	return -1;
     }
 
+    /* Nullify counters here */
+    sprintf(ctc_coverage_cmd, "/bin/cat %s > /dev/null", CTC_COVERAGE); system(ctc_coverage_cmd);
     if ((cpid = fork()) < 0) {
 	fprintf(stderr, "pan(%s): fork failed (tag %s).  errno:%d  %s\n",
 		panname, colle->name, errno, strerror(errno));
@@ -875,7 +894,6 @@
 	    char **arg_v;
 
 	    arg_v = (char **)splitstr(c_cmdline, NULL, NULL);
-	    
 	    execvp(arg_v[0], arg_v);
     	    errlen = sprintf(errbuf,
 		    "pan(%s): execvp of '%s' (tag %s) failed.  errno:%d  %s",
@@ -926,6 +944,8 @@
 	    termtype = "unknown";
 	}
 	time(&end_time);
+	sprintf(ctc_coverage_cmd, "/bin/cat %s > %s/%s.MON.txt", CTC_COVERAGE, ctc_out_dir, colle->name); system(ctc_coverage_cmd);
+	    
 	if (!quiet_mode) 
 	{
 		write_test_start(active, errbuf);
