Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Combination of pipes and &! leaks file descriptors



On Tue, 2 May 2017 16:19:25 +0200
Jure Varlec <jure@xxxxxxxxx> wrote:
> I noticed a file descriptor leak today in a script that was forking
> jobs in a loop and ceased to work after 1000 jobs. A (quick, admittedly)
> search of the mailing list found nothing relevant. A minimal example is
> attached, using `lsof` to demonstrate the problem. I also attached its
> output in case there are difficulties reproducing the problem. It is
> interesting to see that only the `&!` operator causes the problem, the
> `disown` command does not. A pipe needs to be present in the
> backgrounded command.

Thanks, this made it easy to track down.

pws

diff --git a/Src/exec.c b/Src/exec.c
index 9a75dd2..debb0ae 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -1612,6 +1612,7 @@ execpline(Estate state, wordcode slcode, int how, int last1)
 	    zclose(opipe[0]);
 	}
 	if (how & Z_DISOWN) {
+	    pipecleanfilelist(jobtab[thisjob].filelist, 0);
 	    deletejob(jobtab + thisjob, 1);
 	    thisjob = -1;
 	}



Messages sorted by: Reverse Date, Date, Thread, Author