Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: bug with eval, proc-subst and pipes
On Thu, 18 Jul 2013 10:22:27 +0100
Peter Stephenson <p.stephenson@xxxxxxxxxxx> wrote:
> On Thu, 18 Jul 2013 09:57:41 +0100
> Peter Stephenson <p.stephenson@xxxxxxxxxxx> wrote:
> > Will it be good enough to go through all process substitution output
> > file descriptors for a job when we enter zwaitjob() and close them? I
> > think at that point nothing more can write from the main shell process,
> > and subprocesses in any case have to manage their own copies of the file
> > descriptor.
>
> Thinking about it, it would presumably be safe just to close all
> temporary file descriptors at that point, including input, since there's
> nothing in the job that can read input now, either. So there's no need
> to distinguish input and output. We keep the existing close logic as a
> backup. I don't think it's safe to delete temporary files yet, however,
> since unlike the file descriptors, which are local to the process, those
> can be accessed directly by subprocesses still running.
Apparently working (except for the fact it doesn't fix Stephane's
original problem, don't know if we're any further forward with that).
However, I'll wait in case Bart can see something I missed.
diff --git a/Src/jobs.c b/Src/jobs.c
index a1955bb..432f0f5 100644
--- a/Src/jobs.c
+++ b/Src/jobs.c
@@ -1368,6 +1368,30 @@ zwaitjob(int job, int wait_cmd)
jn->stat |= STAT_LOCKED;
if (jn->stat & STAT_CHANGED)
printjob(jn, !!isset(LONGLISTJOBS), 1);
+ if (jn->filelist) {
+ /*
+ * The main shell is finished with any file descriptors used
+ * for process substitution associated with this job: close
+ * them to indicate to listeners there's no more input.
+ *
+ * Note we can't safely delete temporary files yet as these
+ * are directly visible to other processes. However,
+ * we can't deadlock on the fact that those still exist, so
+ * that's not a problem.
+ */
+ LinkNode node = firstnode(jn->filelist);
+ while (node) {
+ Jobfile jf = (Jobfile)getdata(node);
+ if (jf->is_fd) {
+ LinkNode next = nextnode(node);
+ (void)remnode(jn->filelist, node);
+ zclose(jf->u.fd);
+ node = next;
+ } else {
+ incnode(node);
+ }
+ }
+ }
while (!errflag && jn->stat &&
!(jn->stat & STAT_DONE) &&
!(interact && (jn->stat & STAT_STOPPED))) {
pws
Messages sorted by:
Reverse Date,
Date,
Thread,
Author