e52d733af1cd260a9aee37e2f4371e8f841e6191 markd Fri Jan 7 13:30:04 2011 -0800 made an error message more informative Bug #1201 diff --git src/lib/pipeline.c src/lib/pipeline.c index f79abcd..3a671f4 100644 --- src/lib/pipeline.c +++ src/lib/pipeline.c @@ -76,31 +76,31 @@ static char* joinCmd(char **cmd) /* join an cmd vector into a space separated string */ { struct dyString *str = dyStringNew(512); int i; for (i = 0; cmd[i] != NULL; i++) { if (i > 0) dyStringAppend(str, " "); dyStringAppend(str, cmd[i]); } return dyStringCannibalize(&str); } static char* joinCmds(char ***cmds) -/* join an cmds vetor into a space and pipe seperated string */ +/* join an cmds vetor into a space and pipe separated string */ { struct dyString *str = dyStringNew(512); int i, j; for (i = 0; cmds[i] != NULL; i++) { if (i > 0) dyStringAppend(str, " | "); for (j = 0; cmds[i][j] != NULL; j++) { if (j > 0) dyStringAppend(str, " "); dyStringAppend(str, cmds[i][j]); } } return dyStringCannibalize(&str); @@ -282,32 +282,33 @@ } freez(&pl->procName); freez(&pl->stdioBuf); freez(plPtr); } } static void execProcChild(struct pipeline* pl, struct plProc *proc, int procStdinFd, int procStdoutFd, int stderrFd, void *otherEndBuf, size_t otherEndBufSize) /* handle child process setup after fork. This does not return */ { if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) errnoAbort("error ignoring SIGPIPE"); // set process group to first subprocess id, which might be us -if (setpgid(getpid(), ((pl->pgid < 0) ? getpid() : pl->pgid))) - errnoAbort("error from setpgid"); +pid_t pgid = (pl->pgid < 0) ? getpid() : pl->pgid; +if (setpgid(getpid(), pgid) != 0) + errnoAbort("error from setpgid(%d, %d)", getpid(), pgid); if (otherEndBuf != NULL) plProcMemWrite(proc, procStdoutFd, stderrFd, otherEndBuf, otherEndBufSize); else plProcExecChild(proc, procStdinFd, procStdoutFd, stderrFd); } static int pipelineExecProc(struct pipeline* pl, struct plProc *proc, int prevStdoutFd, int stdinFd, int stdoutFd, int stderrFd, void *otherEndBuf, size_t otherEndBufSize) /* start a process in the pipeline, return the stdout fd of the process */ { /* determine stdin/stdout to use */ int procStdinFd, procStdoutFd; if (proc == pl->procs)