3d8cc972aeac2f853c867a4b4bbbc1b78ae85c7c
kent
  Fri Sep 5 17:04:21 2014 -0700
Adding new pipelineClose() function that combines pipelineWait and pipelineFree and applying it where it makes sense, in some cases fixing non-symptomatic bugs from missing pipelineWaits
diff --git src/inc/pipeline.h src/inc/pipeline.h
index 00ad819..27f6f37 100644
--- src/inc/pipeline.h
+++ src/inc/pipeline.h
@@ -26,49 +26,47 @@
  * An example that reads a compressed file, sorting it numerically by the 
  * first column:
  *    
  *    static char *cmd1[] = {"gzip", "-dc", NULL};
  *    static char *cmd2[] = {"sort", "-k", "1,1n", NULL};
  *    static char **cmds[] = {cmd1, cmd2, NULL};
  *    
  *    struct pipeline *pl = pipelineOpen(cmds, pipelineRead, inFilePath, stderrFd);
  *    struct lineFile *lf = pipelineLineFile(pl);
  *    char *line;
  *    
  *    while (lineFileNext(lf, &line, NULL))
  *        {
  *        ...
  *        }
- *    pipelineWait(pl);
- *    pipelineFree(&pl);
+ *    pipelineClose(&pl);
  *
  * A similar example that generates data and writes a compressed file, sorting
  * it numerically by the first column:
  *    
  *    
  *    static char *cmd1[] = {"sort", "-k", "1,1n", NULL};
  *    static char *cmd2[] = {"gzip", "-c3", NULL};
  *    static char **cmds[] = {cmd1, cmd2, NULL};
  *    
  *    struct pipeline *pl = pipelineOpen(cmds, pipelineWrite, outFilePath, stderrFd);
  *    char *line;
  *    
  *    while ((line = makeNextRow()) != NULL)
  *        fprintf(fh, "%s\n", line);
  *    
- *    pipelineWait(pl);
- *    pipelineFree(&pl);
+ *    pipelineClose(&pl);
  *
  * To append to an output file, use pipelineWrite|pipelineAppend:
  *    
  *    struct pipeline *pl = pipelineOpen(cmds, pipelineWrite|pipelineAppend, outFilePath, stderrFd);
  */
 #ifndef PIPELINE_H
 #define PIPELINE_H
 #include <stdio.h>
 struct linefile;
 struct pipeline;
 
 enum pipelineOpts
 /* pipeline options bitset */
     {
     pipelineRead       = 0x01, /* read from pipeline */
@@ -135,21 +133,25 @@
  * function.  Subsequent calls return the same FILE.*/
 
 struct lineFile *pipelineLineFile(struct pipeline *pl);
 /* Get a lineFile object wrapped around the pipeline.  Do not close the
  * lineFile, is owned by the pipeline object.  A lineFile is created on first
  * call to this function.  Subsequent calls return the same object.*/
 
 int pipelineWait(struct pipeline *pl);
 /* Wait for processes in a pipeline to complete; normally aborts if any
  * process exists non-zero.  If pipelineNoAbort was specified, return the exit
  * code of the first process exit non-zero, or zero if none failed. */
 
 void pipelineFree(struct pipeline **plPtr);
 /* free a pipeline object */
 
+int pipelineClose(struct pipeline **pPl);
+/* Wait for pipeline to finish and free it. Same as pipelineWait then pipelineClose.
+ * Returns pipelineWait result (normally 0). */
+
 #endif
 /*
  * Local Variables:
  * c-file-style: "jkent-c"
  * End:
  */