6f949e90b1ba3de976455fbcf9da21897761d134
markd
  Fri Oct 29 16:11:58 2021 -0700
add timeout option to pipeline to allow kill long-running pipelines, especially ones run from CGIs

diff --git src/hg/hgc/hgdpClick.c src/hg/hgc/hgdpClick.c
index 7c1fe18..ef55962 100644
--- src/hg/hgc/hgdpClick.c
+++ src/hg/hgc/hgdpClick.c
@@ -183,31 +183,31 @@
 static char *psxyPieAmCmd[] =
     {"", "", AM_REGION, AM_PROJ, PSXY_PIX, PSXY_CONT_PLOT, PSXY_CONT_PS,
      PSXY_WEDGE, "-Gblue", NULL};
 static char *psxyBlueAmCmd[] =
     {"", "", AM_REGION, AM_PROJ, PSXY_PIX, PSXY_CONT_PLOT,
      PSXY_CIRCLE, "-Gblue", NULL};
 
 static void runCommandAppend(char *cmd[], char *program, char *inFile, char *outFile)
 /* Use the pipeline module to run a single command pipelineWrite|pipelineAppend. */
 {
 char **cmds[2];
 cmds[0] = cmd;
 cmds[1] = NULL;
 cmd[0] = program;
 cmd[1] = inFile;
-struct pipeline *pl = pipelineOpen(cmds, pipelineWrite|pipelineAppend, outFile, NULL);
+struct pipeline *pl = pipelineOpen(cmds, pipelineWrite|pipelineAppend, outFile, NULL, 0);
 pipelineClose(&pl);
 }
 
 static void removeDir(char *dirName)
 /* Remove all files in a directory and the directory itself. */
 // NOTE: If this is ever to be libified, beef it up:
 // 1. Add recursion to subdirs (maybe enabled by a new boolean arg)
 // 2. Make sure dirName exists
 // 3. Make sure current dir is not dirName or a subdir of dirName
 {
 struct slName *file;
 struct dyString *dy = dyStringNew(0);
 for (file = listDir(dirName, "*");  file != NULL;  file = file->next)
     {
     dyStringClear(dy);
@@ -279,40 +279,40 @@
     errAbort("How did this get called?  hg.conf doesn't have hgc.psxyPath.");
 runCommandAppend(psxyOrangeAeaCmd, psxy, pieFile, epsFile);
 runCommandAppend(psxyPieAeaCmd, psxy, pieFile, epsFile);
 runCommandAppend(psxyBlueAeaCmd, psxy, circleFile, epsFile);
 runCommandAppend(psxyOrangeAmCmd, psxy, pieFile, epsFile);
 runCommandAppend(psxyPieAmCmd, psxy, pieFile, epsFile);
 runCommandAppend(psxyBlueAmCmd, psxy, circleFile, epsFile);
 
 // Make PDF and PNG:
 struct pipeline *pl;
 char pdfFile[FILENAME_LEN], pngFile[FILENAME_LEN];
 safef(pdfFile, sizeof(pdfFile), "%s.pdf", rootName);
 safef(pngFile, sizeof(pngFile), "%s.png", rootName);
 char *ps2pdfCmd[] = {"ps2pdf", epsFile, pdfFile, NULL};
 char **cmdsPdf[] = {ps2pdfCmd, NULL};
-pl = pipelineOpen(cmdsPdf, pipelineWrite, "/dev/null", NULL);
+pl = pipelineOpen(cmdsPdf, pipelineWrite, "/dev/null", NULL, 0);
 pipelineClose(&pl);
 
 char *ps2raster = cfgOption("hgc.ps2rasterPath");
 char *ghostscript = cfgOption("hgc.ghostscriptPath");
 char gsOpt[PATH_LEN];
 safef(gsOpt, sizeof(gsOpt), "-G%s", ghostscript);
 char *ps2RasterPngCmd[] = {ps2raster, gsOpt, "-P", "-A", "-Tg", "-E150", epsFile, NULL};
 char **cmdsPng[] = {ps2RasterPngCmd, NULL};
-pl = pipelineOpen(cmdsPng, pipelineRead, "/dev/null", NULL);
+pl = pipelineOpen(cmdsPng, pipelineRead, "/dev/null", NULL, 0);
 pipelineClose(&pl);
 
 // Back to our usual working directory and $HOME:
 if (realHome == NULL)
     unsetenv("HOME");
 else
     setenv("HOME", realHome, TRUE);
 mustChdir(cwd);
 
 // Move the result files into place:
 char tmpPath[PATH_LEN];
 safef(tmpPath, sizeof(tmpPath), "%s/%s", dirTn.forCgi, epsFile);
 mustRename(tmpPath, finalEpsFile);
 safef(tmpPath, sizeof(tmpPath), "%s/%s", dirTn.forCgi, pdfFile);
 mustRename(tmpPath, finalPdfFile);