Index: /trunk/splitpipe/blah
===================================================================
--- /trunk/splitpipe/blah	(revision 344)
+++ /trunk/splitpipe/blah	(revision 348)
@@ -1,3 +1,2 @@
 #!/bin/sh
-
-cat > output.$$
+cdrecord dev=/dev/sr0 speed=24 -tao -v -gracetime 2 driveropts=burnfree fs=20m -data - 
Index: /trunk/splitpipe/main.cc
===================================================================
--- /trunk/splitpipe/main.cc	(revision 346)
+++ /trunk/splitpipe/main.cc	(revision 348)
@@ -7,4 +7,5 @@
 #include <sys/wait.h>
 #include <stdint.h>
+#include <signal.h>
 
 #include "ringbuffer.hh"
@@ -26,4 +27,7 @@
   } predefinedSizes[]= { 
     {"floppy", 1440000 }, 
+    {"CD", 650000000ULL }, 
+    {"CD-80", 700000000ULL }, 
+    {"CDR-80", 700000000ULL }, 
     {"DVD", 4700000000ULL }, 
     {"DVD-5", 4700000000ULL }, 
@@ -38,4 +42,12 @@
 }
 
+bool g_havebreak;
+
+void breakHandler(int t)
+{
+  cerr<<"\nsplitpipe: Received interrupt request, terminating output"<<endl;
+  g_havebreak=true;
+}
+
 void unixDie(const string& during)
 {
@@ -63,5 +75,5 @@
   cerr<<"splitpipe syntax:\n\n";
   cerr<<" --buffer-size, -b\tSize of buffer before output, in megabytes"<<endl;
-  cerr<<" --chunk-size, -c\tSize of output chunks, in kilobytes, or use 'DVD', 'CDR' or 'CDR80'"<<endl;
+  cerr<<" --chunk-size, -c\tSize of output chunks, in kilobytes, or use 'DVD', 'CDR' or 'CDR-80'"<<endl;
   cerr<<" --help, -h\t\tGive this helpful message"<<endl;
   cerr<<" --verbose, -v\t\tGive verbose output\n\n";
@@ -160,4 +172,6 @@
   ParseCommandline(argc, argv);
 
+  signal(SIGPIPE, SIG_IGN);
+  signal(SIGINT, breakHandler);
   cerr.setf(ios::fixed);
   cerr.precision(2);
@@ -170,5 +184,9 @@
 
   if(parameters.outputCommand.empty()) {
-    cerr<<"No output command specified - unable to write data"<<endl;
+    cerr<<"No output command specified - unable to write data\n\n";
+    cerr<<"Suggested command for cd: \n";
+    cerr<<"cdrecord dev=/dev/cdrom speed=24 -eject -dummy -tao\n";
+    cerr<<"\nSuggested command for dvd: \n";
+    cerr<<"growisofs -Z/dev/dvd=/dev/stdin -dry-run\n";
     exit(1);
   }
@@ -195,8 +213,29 @@
 
   char *buffer = new char[parameters.bufferSize];
+
+  if(parameters.verbose) 
+    cerr<<"Prebuffering before starting output script..";
+
+  bool d_firstchunk=true;
+
   while(1) {
 
     if(!outputOnline && (inputEof || (1.0 * rb.available() / parameters.bufferSize > 0.5))) {
-      cerr<<"bringing output script online - buffer " << 100.0*rb.available() / parameters.bufferSize <<"% full"<<endl;
+      if(d_firstchunk) {
+	cerr<<" done"<<endl;;
+	d_firstchunk=false;
+      }
+      else {
+	cerr<<"\nsplitpipe: reload media, if necessary, and press enter to continue"<<endl;
+	FILE *fp=fopen("/dev/tty", "r");
+	if(!fp) 
+	  unixDie("opening of /dev/tty for user input");
+
+	char line[80];
+	fgets(line, sizeof(line) - 1, fp);
+	fclose(fp);
+      }
+
+      cerr<<"splitpipe: bringing output script online - buffer " << 100.0*rb.available() / parameters.bufferSize <<"% full"<<endl;
       outputfd=spawnOutputThread();
       outputOnline=true;
@@ -252,9 +291,19 @@
 	
 	if(!len) {
-	  cerr<<"Output a full chunk, closing pipe, waiting for output command to exit..";
+	  cerr<<"\nsplitpipe: output a full chunk, closing pipe, waiting for output command to exit..\n";
 	  close(outputfd);
 	  int status;
-	  waitpid(g_pid, &status, 0);
-	  cerr<<" done!"<<endl;
+	  if(waitpid(g_pid, &status, 0) < 0)
+	    unixDie("wait on child process");
+
+	  if(WIFEXITED(status))
+	    cerr<<"\nsplitpipe: output command exited with status "<<WEXITSTATUS(status)<<endl;
+	  else {
+	    cerr<<"\nsplitpipe: output command exited abnormally";
+	    if(WIFSIGNALED(status))
+	      cerr<<", by signal "<<WTERMSIG(status);
+	    cerr<<endl;
+	  }
+	  
 	  outputOnline=false;
 	  outputfd=-1;
@@ -288,5 +337,5 @@
 	//	else
 	//	  cerr<<getTime()-startTime<<"\t"<<rb.available()<<"\n";
-      }while(totalBytes < bytesRead && rb.available());
+      } while(totalBytes < bytesRead && rb.available());
     }
 
@@ -296,9 +345,15 @@
 
   if(outputOnline) {
-    cerr<<"Done with input, waiting for output script to exit..";
+    cerr<<"\nsplitpipe: done with input, waiting for output script to exit..\n";
     close(outputfd);
     int status;
     waitpid(g_pid, &status, 0);
-    cerr<<" done!"<<endl;
+    if(WIFEXITED(status))
+      cerr<<"\nsplitpipe: output command exited with status "<<WEXITSTATUS(status)<<endl;
+    else {
+      cerr<<"\nsplitpipe: output command exited abnormally";
+      if(WIFSIGNALED(status))
+	cerr<<", by signal "<<WTERMSIG(status)<<endl;
+    }
   }
 
