Re: Several issues with coprocesses regarding exit status

2012-12-13 Thread DJ Mills
On Thu, Dec 13, 2012 at 3:42 PM, Chet Ramey wrote: > It's a race to see whether or not the coprocess exits and is reaped and > cleaned up before wait executes. `false' is a very short-lived process, > doesn't require an exec, and so I would expect the child to exit very > quickly. The cleanup,

Re: Several issues with coprocesses regarding exit status

2012-12-13 Thread Chet Ramey
On 12/11/12 2:31 PM, DJ Mills wrote: The first two have been covered in other messages. > > 3) > The first two issues aren't THAT big of a deal, because you can simply not > worry about coproc's exit status and use wait's. That's the idea; the coproc command itself returns an indication of

Re: Several issues with coprocesses regarding exit status

2012-12-13 Thread DJ Mills
On Thu, Dec 13, 2012 at 2:32 PM, Chet Ramey wrote: > On 12/12/12 3:11 AM, Andreas Schwab wrote: > > >> To reproduce: > >> if ! coproc false; then echo error1 >&2; fi; wait "$COPROC_PID" || > echo > >> error2 >&2 > > > > This has nothing to do with if but with ! which doesn't appear to work

Re: Several issues with coprocesses regarding exit status

2012-12-13 Thread Chet Ramey
On 12/12/12 3:11 AM, Andreas Schwab wrote: >> To reproduce: >> if ! coproc false; then echo error1 >&2; fi; wait "$COPROC_PID" || echo >> error2 >&2 > > This has nothing to do with if but with ! which doesn't appear to work > in this context. Correct; good catch. It was an oversight and w

Re: Several issues with coprocesses regarding exit status

2012-12-12 Thread Chet Ramey
On 12/11/12 2:49 PM, Greg Wooledge wrote: > So, I'd just call it a documentation flaw. Most likely "coproc" is > indicating whether it successfully created the coprocess (bg job), and > you'll have to use "wait" to fetch its exit status once it becomes > available. More like an omission. The cu

Re: Several issues with coprocesses regarding exit status

2012-12-12 Thread Andreas Schwab
DJ Mills writes: > 2) > However, the exception to #1 is my second issue, with is that coproc > always > seems to fail when called within the test portion of an if statement. I > have > absolutely no idea why this happens. > > To reproduce: > if ! coproc false; then echo error1 >&2; fi

Re: Several issues with coprocesses regarding exit status

2012-12-11 Thread DJ Mills
On Tue, Dec 11, 2012 at 2:49 PM, Greg Wooledge wrote: > Since coproc creates a background job, it doesn't really makes sense that > the "coproc" command itself would know the exit status of the background > job. It would have to wait for the background job to terminate first, > which would defea

Re: Several issues with coprocesses regarding exit status

2012-12-11 Thread Greg Wooledge
On Tue, Dec 11, 2012 at 02:31:28PM -0500, DJ Mills wrote: > First of all, the man page and help output state: > `The return status of a coprocess is the exit status of command.' > No matter what, coproc seems to always return true. > > To reproduce: > coproc false || echo error1 >&2;