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/lib/pipeline.c src/lib/pipeline.c
index 68e9f33..d56ad26 100644
--- src/lib/pipeline.c
+++ src/lib/pipeline.c
@@ -677,30 +677,44 @@
         errAbort("close failed on pipeline: %s ", pl->procName);
     }
 pl->pipeFd = -1;
 }
 
 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. */
 {
 /* must close before waiting to so processes get pipe EOF */
 closePipeline(pl);
 return groupLeaderWait(pl);
 }
 
+int pipelineClose(struct pipeline **pPl)
+/* Wait for pipeline to finish and free it. Same as pipelineWait then pipelineClose.
+ * Returns pipelineWait result (normally 0). */
+{
+struct pipeline *pl = *pPl;
+int ret = 0;
+if (pl != NULL)
+    {
+    ret = pipelineWait(pl);
+    pipelineFree(pPl);
+    }
+return ret;
+}
+
 void pipelineSetNoAbort(struct pipeline *pl)
 /* Make it so pipeline won't abort on error - can be done after the fact.
  * (This is needed to close a pipelined lineFile early.) */
 {
 pl->options |= pipelineNoAbort;
 }
 
 void pipelineDumpCmds(char ***cmds)
 /* Dump out pipeline-formatted commands to stdout for debugging. */
 {
 char **cmd;
 boolean first = TRUE;
 while ((cmd = *cmds++) != NULL)
    {
    char *word;