tcsh being dodgy, or pipe code ishoos?

Juli Mallett jmallett at FreeBSD.org
Tue Jun 24 22:15:25 PDT 2003


* Juli Mallett <jmallett at FreeBSD.org> [ Date: 2003-06-24 ]
	[ w.r.t. Re: tcsh being dodgy, or pipe code ishoos? ]
> * Tim Kientzle <kientzle at acm.org> [ Date: 2003-06-24 ]
> > Hmmm... This looks like xargs isn't waiting for the subcommand
> > to exit.  This looks like 'echo -- + 2' and 'echo -- + 3' are
> > running concurrently.
> 
> How about this, it essentially says that in the not -P case, no procs
> may be unwaited-on, whereas otherwise we say that 1 may be unwaited-on..


jmg@ points out this better idea, of doing the waitchildren before the
vfork, allowing xargs to do its work while the child runs, as seems to
be the desirable effect of having maxprocs=1, so.

%%%
Index: xargs.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/xargs/xargs.c,v
retrieving revision 1.54
diff -u -r1.54 xargs.c
--- xargs.c     13 Jun 2003 17:05:41 -0000      1.54
+++ xargs.c     25 Jun 2003 05:12:27 -0000
@@ -518,6 +518,8 @@
        }
 exec:
        childerr = 0;
+       curprocs++;
+       waitchildren(*argv, 0);
        switch(pid = vfork()) {
        case -1:
                err(1, "vfork");
@@ -537,8 +539,6 @@
                childerr = errno;
                _exit(1);
        }
-       curprocs++;
-       waitchildren(*argv, 0);
 }
  
 static void
%%%
-- 
juli mallett. email: jmallett at freebsd.org; efnet: juli;


More information about the freebsd-current mailing list