zsh-workers
 help / color / mirror / code / Atom feed
* Y03arguments.ztst fails
@ 2003-04-23 15:15 Peter Whaite
  2003-04-25 10:42 ` Peter Stephenson
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Whaite @ 2003-04-23 15:15 UTC (permalink / raw)
  To: zsh-workers


% cat /etc/issue

Red Hat Linux release 7.1 (Seawolf)
Kernel 2.4.14 on an i686

has failed last couple of days from cvs version...

./Y03arguments.ztst: starting.
*** /tmp/zsh.ztst.out.5181      Wed Apr 23 10:49:24 2003
--- /tmp/zsh.ztst.tout.5181     Wed Apr 23 10:49:24 2003
***************
*** 1,8 ****
  line: {tst -o }{}
! line: {tst -o +o }{}
! line: {tst -o +o }{}
  MESSAGE:{no arguments}
! line: {tst +o }{}
! line: {tst +o -o }{}
! line: {tst +o -o }{}
  MESSAGE:{no arguments}
--- 1,8 ----
  line: {tst -o }{}
! line: {tst -o }{}
  MESSAGE:{no arguments}
! line: {tst -o }{}
  MESSAGE:{no arguments}
+ line: {+}{}
+ line: {+}{}
+ line: {+}{}
Test ./Y03arguments.ztst failed: output differs from expected as shown above for
:
 tst_arguments -+o
 comptest $'tst -\t\t\t\C-w\C-w+\t\t\t'
Was testing: option beginning with + and -.
./Y03arguments.ztst: test failed.

--
peta


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Y03arguments.ztst fails
  2003-04-23 15:15 Y03arguments.ztst fails Peter Whaite
@ 2003-04-25 10:42 ` Peter Stephenson
  2003-04-26 19:27   ` Peter Stephenson
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 2003-04-25 10:42 UTC (permalink / raw)
  To: zsh-workers

I'm seeing these failures in Y03arguments.ztst too, they don't seem to
be there in 4.1.1-test-1.  I would think it's more likely to be in the
functions than the C code, since no-one dares touch the latter.

I'm also getting random failures with multios tests which I haven't seen
before.  I don't think the underlying problem is new, I think it's the
same issue as this comment:

# Following two tests have to be separated since in
#   print bar >foo >bar && print "$(<foo) $(<bar)"
# the multios aren't flushed until after the substitutions take
# place.  This can't be right.

--- separating the tests doesn't actually fix the race.  I can insert a
`sleep' but it's a bit nasty.  Unfortunately, the multios have to be
asynchronous (or we end up with something like DOS's bizarre pipe
implementation) so this is pretty fundamental.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Y03arguments.ztst fails
  2003-04-25 10:42 ` Peter Stephenson
@ 2003-04-26 19:27   ` Peter Stephenson
  2003-04-30 19:08     ` PATCH: wait for auxiliary processes Peter Stephenson
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 2003-04-26 19:27 UTC (permalink / raw)
  To: zsh-workers

Peter Stephenson wrote:
> I'm seeing these failures in Y03arguments.ztst too, they don't seem to
> be there in 4.1.1-test-1.  I would think it's more likely to be in the
> functions than the C code, since no-one dares touch the latter.

It's the change below from 18458.  Oliver, what's the right fix?  I presume
the test needs updating to add some `+'s explicitly, or to set the
style.  The latter is probably easiest --- adding 

zstyle ":completion:*:options" prefix-needed no

to comptest makes Y03arguments.ztst pass.

Index: _describe
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Utility/_describe,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -p -r1.13 -r1.14
--- _describe	23 May 2002 12:16:42 -0000	1.13
+++ _describe	22 Apr 2003 12:33:08 -0000	1.14
@@ -20,6 +20,10 @@ elif [[ "$1" = -t* ]]; then
   shift
 fi
 
+[[ "$_type" = options && ! -prefix [-+]* ]] && \
+    zstyle -T ":completion:${curcontext}:options" prefix-needed &&
+        return 1
+
 # Do the tests. `showd' is set if the descriptions should be shown.
 
 zstyle -T ":completion:${curcontext}:$_type" verbose && _showd=yes


> I'm also getting random failures with multios tests which I haven't seen
> before.  I don't think the underlying problem is new, I think it's the
> same issue as this comment:
> 
> # Following two tests have to be separated since in
> #   print bar >foo >bar && print "$(<foo) $(<bar)"
> # the multios aren't flushed until after the substitutions take
> # place.  This can't be right.

Grud.  I can partially fix this by storing a list of auxiliary processes
for which the job should wait.  This applies for both multios and >(...)
subsituttions.  Unfortunately there are two problems.

1. It only works for builtins.  This is because in e.g. `cat > >(...)'
the cat is forked before the >(...), so that doesn't get into the job
table of the shell which is waiting for the cat.  The only two obvious
fixes are (i) reorder the fork of >(...) to before the fork of the cat
--- messy and inefficient, requiring extra management of file
descriptors in the parent shell (as is currently done for builtins) (ii)
make the cat process fork again and wait for both the cat and the >(...)
(since it's not feasible to assume one must exit before the other) ---
even messier and more inefficient.  [Waiting for cats to do anything is
always frustrating.]

2. It doesn't always work even then.  Possibly this is because I've got
my wires crossed and haven't implemented properly, but also possibly
it's to do with the additional complexities for handling processes in
the current shell, a.k.a. `list_pipe', see exec.c passim.  Anyway, it
seems to work from the command line, and for the multios tests, but it
doesn't work for this test in D03procsubst.ztst:

  paste <(cut -f2 FILE1) <(cut -f4 FILE2) > >(sed 's/e/E/g' >OUTFILE)
  sleep 1       # since the sed is asynchronous
  cat OUTFILE
0:>(...) substitution
>SEcond ViErtE

even in the modified form:

# slightly desperate hack to force >(...) to be synchronous
  { paste <(cut -f2 FILE1) <(cut -f4 FILE2) } > >(sed 's/e/E/g' >OUTFILE)
  cat OUTFILE
0:>(...) substitution
>SEcond	ViErtE

In fact, I'm fairly clueless about which tests in the list_pipe code
should be modified to look at the auxiliary process list as well as the
main process list.  So I've given up on this for now.

-- 
Peter Stephenson <pws@pwstephenson.fsnet.co.uk>
Work: pws@csr.com
Web: http://www.pwstephenson.fsnet.co.uk


^ permalink raw reply	[flat|nested] 5+ messages in thread

* PATCH: wait for auxiliary processes
  2003-04-26 19:27   ` Peter Stephenson
@ 2003-04-30 19:08     ` Peter Stephenson
  2003-05-02 10:31       ` PATCH: tidy up for test-2 Peter Stephenson
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 2003-04-30 19:08 UTC (permalink / raw)
  To: zsh-workers

Peter Stephenson wrote:
> > I'm also getting random failures with multios tests which I haven't seen
> > before.  I don't think the underlying problem is new, I think it's the
> > same issue as this comment:
> > 
> > # Following two tests have to be separated since in
> > #   print bar >foo >bar && print "$(<foo) $(<bar)"
> > # the multios aren't flushed until after the substitutions take
> > # place.  This can't be right.
> 
> I can partially fix this by storing a list of auxiliary processes
> for which the job should wait.
>
> Anyway, it
> seems to work from the command line, and for the multios tests, but it
> doesn't work for this test in D03procsubst.ztst:
> 
> # slightly desperate hack to force >(...) to be synchronous
>   { paste <(cut -f2 FILE1) <(cut -f4 FILE2) } > >(sed 's/e/E/g' >OUTFILE)
>   cat OUTFILE
> 0:>(...) substitution
> >SEcond	ViErtE

I've traced the problem here.  The function execcursh() which handles `{
... }' executes a `deletejob()' at the start.  I think (does anyone
know?) this is simply to avoid the job table being filled up with
unnecessary entries, and hence not deleting the job when there are
processes to tidy up is unobjectionable.  I was protected from the
consesquences of this when executing the same code from the command line
by the `list_pipe' test.

I'm now confident enough to publish the code and document the fact that
it works only for builtins and the workaround shown in the test code.
Please tell me if you think I'm off my trolley... let me rephrase
that... please tell me if you think this is a bad idea.


Index: Doc/Zsh/expn.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/expn.yo,v
retrieving revision 1.44
diff -u -r1.44 expn.yo
--- Doc/Zsh/expn.yo	3 Apr 2003 10:24:55 -0000	1.44
+++ Doc/Zsh/expn.yo	30 Apr 2003 20:01:30 -0000
@@ -332,7 +332,16 @@
 pastes the results together, and sends it to the processes
 var(process1) and var(process2).
 
-Both the tt(/dev/fd) and the named pipe implementation have drawbacks.  In
+If tt(=LPAR())var(...)tt(RPAR()) is used instead of
+tt(<LPAR())var(...)tt(RPAR()),
+then the file passed as an argument will be the name
+of a temporary file containing the output of the var(list)
+process.  This may be used instead of the tt(<)
+form for a program that expects to lseek (see manref(lseek)(2))
+on the input file.
+
+The tt(=) form is useful as both the tt(/dev/fd) and the named pipe
+implementation of tt(<LPAR())var(...)tt(RPAR()) have drawbacks.  In 
 the former case, some programmes may automatically close the file
 descriptor in question before examining the file on the command line,
 particularly if this is necessary for security reasons such as when the
@@ -353,12 +362,25 @@
 The shell uses pipes instead of FIFOs to implement the latter
 two process substitutions in the above example.
 
-If tt(=) is used,
-then the file passed as an argument will be the name
-of a temporary file containing the output of the var(list)
-process.  This may be used instead of the tt(<)
-form for a program that expects to lseek (see manref(lseek)(2))
-on the input file.
+There is an additional problem with tt(>LPAR())var(process)tt(RPAR()); when
+this is attached to an external command, the parent shell does not wait
+for var(process) to finish and hence an immediately following command
+cannot rely on the results being complete.  The problem and solution are
+the same as described in the section em(MULTIOS) in
+ifzman(zmanref(zshmisc))\
+ifnzman(noderef(Redirection)).  Hence in a simplified
+version of the example above:
+
+example(tt(paste <LPAR()cut -f1) var(file1)tt(RPAR() <LPAR()cut -f3) var(file2)tt(RPAR()) tt(> >LPAR())var(process)tt(RPAR()))
+
+(note that no tt(MULTIOS) are involved), var(process) will be run
+asynchronsously.  The workaround is:
+
+example(tt({ paste <LPAR()cut -f1) var(file1)tt(RPAR() <LPAR()cut -f3) var(file2)tt(RPAR() }) tt(> >LPAR())var(process)tt(RPAR()))
+
+The extra processes here are
+spawned from the parent shell which will wait for their completion.
+
 texinode(Parameter Expansion)(Command Substitution)(Process Substitution)(Expansion)
 sect(Parameter Expansion)
 cindex(parameter expansion)
Index: Doc/Zsh/redirect.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/redirect.yo,v
retrieving revision 1.5
diff -u -r1.5 redirect.yo
--- Doc/Zsh/redirect.yo	28 Mar 2002 04:22:04 -0000	1.5
+++ Doc/Zsh/redirect.yo	30 Apr 2003 20:01:30 -0000
@@ -209,6 +209,28 @@
 
 when tt(MULTIOS) is unset will truncate bar, and write `tt(foo)' into baz.
 
+There is a problem when an output multio is attached to an external
+program.  A simple example shows this:
+
+example(cat file >file1 >file2
+cat file1 file2)
+
+Here, it is possible that the second `tt(cat)' will not display the full
+contents of tt(file1) and tt(file2) (i.e. the original contents of
+tt(file) repeated twice).
+
+The reason for this is that the multios are spawned before the tt(cat)
+process is forked from the parent shell, so the parent shell does not
+wait for the multios to finish writing data.  This means the command as
+shown can exit before tt(file1) and tt(file2) are completely written.
+As a workaround, it is possible to run the tt(cat) process as part of a
+job in the current shell:
+
+example({ cat file } >file >file2)
+
+Here, the tt({)var(...)tt(}) job will pause to wait for both files to be
+written.
+
 sect(Redirections with no command)
 When a simple command consists of one or more redirection operators
 and zero or more parameter assignments, but no command name, zsh can
Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.49
diff -u -r1.49 exec.c
--- Src/exec.c	7 Mar 2003 12:17:54 -0000	1.49
+++ Src/exec.c	30 Apr 2003 20:01:42 -0000
@@ -318,7 +318,7 @@
 {
     Wordcode end = state->pc + WC_CURSH_SKIP(state->pc[-1]);
 
-    if (!list_pipe && thisjob != list_pipe_job)
+    if (!list_pipe && thisjob != list_pipe_job && !hasprocs(thisjob))
 	deletejob(jobtab + thisjob);
     cmdpush(CS_CURSH);
     execlist(state, 1, do_exec);
@@ -1054,7 +1054,7 @@
 
 		    curjob = newjob;
 		    DPUTS(!list_pipe_pid, "invalid list_pipe_pid");
-		    addproc(list_pipe_pid, list_pipe_text);
+		    addproc(list_pipe_pid, list_pipe_text, 0);
 
 		    /* If the super-job contains only the sub-shell, the
 		       sub-shell is the group leader. */
@@ -1088,13 +1088,13 @@
 		    makerunning(jn);
 		}
 		if (!(jn->stat & STAT_LOCKED)) {
-		    updated = !!jobtab[thisjob].procs;
+		    updated = hasprocs(thisjob);
 		    waitjobs();
 		    child_block();
 		} else
 		    updated = 0;
 		if (!updated &&
-		    list_pipe_job && jobtab[list_pipe_job].procs &&
+		    list_pipe_job && hasprocs(list_pipe_job) &&
 		    !(jobtab[list_pipe_job].stat & STAT_STOPPED)) {
 		    child_unblock();
 		    child_block();
@@ -1143,7 +1143,7 @@
 			    jn->stat |= STAT_SUBJOB | STAT_NOPRINT;
 			    jn->other = pid;
 			}
-			if ((list_pipe || last1) && jobtab[list_pipe_job].procs)
+			if ((list_pipe || last1) && hasprocs(list_pipe_job))
 			    killpg(jobtab[list_pipe_job].gleader, SIGSTOP);
 			break;
 		    }
@@ -1251,7 +1251,7 @@
 		char dummy, *text;
 
 		text = getjobtext(state->prog, state->pc);
-		addproc(pid, text);
+		addproc(pid, text, 0);
 		close(synch[1]);
 		read(synch[0], &dummy, 1);
 		close(synch[0]);
@@ -1388,13 +1388,19 @@
 	struct multio *mn = mfds[fd];
 	char buf[TCBUFSIZE];
 	int len, i;
+	pid_t pid;
 
-	if (zfork()) {
+	if ((pid = zfork())) {
 	    for (i = 0; i < mn->ct; i++)
 		zclose(mn->fds[i]);
 	    zclose(mn->pipe);
+	    if (pid == -1) { 
+		mfds[fd] = NULL;
+		return;
+	    }
 	    mn->ct = 1;
 	    mn->fds[0] = fd;
+	    addproc(pid, NULL, 1);
 	    return;
 	}
 	/* pid == 0 */
@@ -2054,7 +2060,7 @@
 			  3 : WC_ASSIGN_NUM(ac) + 2);
 		}
 	    }
-	    addproc(pid, text);
+	    addproc(pid, text, 0);
             opts[AUTOCONTINUE] = oautocont;
 	    return;
 	}
@@ -2946,38 +2952,28 @@
     Eprog prog;
     int out = *cmd == Inang;
     char *pnam;
+    pid_t pid;
+
 #ifndef PATH_DEV_FD
     int fd;
-#else
-    int pipes[2];
-#endif
 
     if (thisjob == -1)
 	return NULL;
-#ifndef PATH_DEV_FD
     if (!(pnam = namedpipe()))
 	return NULL;
-#else
-    pnam = hcalloc(strlen(PATH_DEV_FD) + 6);
-#endif
     if (!(prog = parsecmd(cmd)))
 	return NULL;
-#ifndef PATH_DEV_FD
     if (!jobtab[thisjob].filelist)
 	jobtab[thisjob].filelist = znewlinklist();
     zaddlinknode(jobtab[thisjob].filelist, ztrdup(pnam));
 
-    if (zfork()) {
-#else
-    mpipe(pipes);
-    if (zfork()) {
-	sprintf(pnam, "%s/%d", PATH_DEV_FD, pipes[!out]);
-	zclose(pipes[out]);
-	fdtable[pipes[!out]] = 2;
-#endif
+    if ((pid = zfork())) {
+	if (pid == -1)
+	    return NULL;
+	if (!out)
+	    addproc(pid, NULL, 1);
 	return pnam;
     }
-#ifndef PATH_DEV_FD
     closem(0);
     fd = open(pnam, out ? O_WRONLY | O_NOCTTY : O_RDONLY | O_NOCTTY);
     if (fd == -1) {
@@ -2986,11 +2982,37 @@
     }
     entersubsh(Z_ASYNC, 1, 0, 0);
     redup(fd, out);
-#else
+#else /* PATH_DEV_FD */
+    int pipes[2];
+
+    if (thisjob == -1)
+	return NULL;
+    pnam = hcalloc(strlen(PATH_DEV_FD) + 6);
+    if (!(prog = parsecmd(cmd)))
+	return NULL;
+    mpipe(pipes);
+    if ((pid = zfork())) {
+	sprintf(pnam, "%s/%d", PATH_DEV_FD, pipes[!out]);
+	zclose(pipes[out]);
+	if (pid == -1)
+	{
+	    zclose(pipes[!out]);
+	    return NULL;
+	}
+	fdtable[pipes[!out]] = 2;
+	if (!out)
+	{
+	    addproc(pid, NULL, 1);
+	    fprintf(stderr, "Proc %d added\n", pid);
+	    fflush(stderr);
+	}
+	return pnam;
+    }
     entersubsh(Z_ASYNC, 1, 0, 0);
     redup(pipes[out], out);
     closem(0);   /* this closes pipes[!out] as well */
-#endif
+#endif /* PATH_DEV_FD */
+
     cmdpush(CS_CMDSUBST);
     execode(prog, 0, 1);
     cmdpop();
@@ -3008,12 +3030,18 @@
 {
     Eprog prog;
     int pipes[2], out = *cmd == Inang;
+    pid_t pid;
 
     if (!(prog = parsecmd(cmd)))
 	return -1;
     mpipe(pipes);
-    if (zfork()) {
+    if ((pid = zfork())) {
 	zclose(pipes[out]);
+	if (pid == -1) {
+	    zclose(pipes[!out]);
+	    return -1;
+	}
+	addproc(pid, NULL, 1);
 	return pipes[!out];
     }
     entersubsh(Z_ASYNC, 1, 0, 0);
@@ -3226,13 +3254,14 @@
     if (errflag)
 	return;
 
-    if (!list_pipe && thisjob != list_pipe_job) {
+    if (!list_pipe && thisjob != list_pipe_job && !hasprocs(thisjob)) {
 	/* Without this deletejob the process table *
 	 * would be filled by a recursive function. */
 	last_file_list = jobtab[thisjob].filelist;
 	jobtab[thisjob].filelist = NULL;
 	deletejob(jobtab + thisjob);
     }
+
     if (isset(XTRACE)) {
 	LinkNode lptr;
 	printprompt4();
Index: Src/jobs.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/jobs.c,v
retrieving revision 1.20
diff -u -r1.20 jobs.c
--- Src/jobs.c	7 Mar 2003 12:17:54 -0000	1.20
+++ Src/jobs.c	30 Apr 2003 20:01:47 -0000
@@ -130,22 +130,36 @@
 
 /**/
 int
-findproc(pid_t pid, Job *jptr, Process *pptr)
+findproc(pid_t pid, Job *jptr, Process *pptr, int aux)
 {
     Process pn;
     int i;
 
     for (i = 1; i < MAXJOB; i++)
-	for (pn = jobtab[i].procs; pn; pn = pn->next)
+    {
+	for (pn = aux ? jobtab[i].auxprocs : jobtab[i].procs;
+	     pn; pn = pn->next)
 	    if (pn->pid == pid) {
 		*pptr = pn;
 		*jptr = jobtab + i;
 		return 1;
 	    }
+    }
 
     return 0;
 }
 
+/* Does the given job number have any processes? */
+
+/**/
+int
+hasprocs(int job)
+{
+    Job jn = jobtab + job;
+
+    return jn->procs || jn->auxprocs;
+}
+
 /* Find the super-job of a sub-job. */
 
 /**/
@@ -168,7 +182,7 @@
 {
     Job jn = jobtab + job, sj = jobtab + jn->other;
 
-    if ((sj->stat & STAT_DONE) || !sj->procs) {
+    if ((sj->stat & STAT_DONE) || (!sj->procs && !sj->auxprocs)) {
 	struct process *p;
 		    
 	for (p = sj->procs; p; p = p->next)
@@ -257,6 +271,10 @@
     int val = 0, status = 0;
     int somestopped = 0, inforeground = 0;
 
+    for (pn = jn->auxprocs; pn; pn = pn->next)
+	if (pn->status == SP_RUNNING)
+	    return;
+
     for (pn = jn->procs; pn; pn = pn->next) {
 	if (pn->status == SP_RUNNING)      /* some processes in this job are running       */
 	    return;                        /* so no need to update job table entry         */
@@ -806,6 +824,13 @@
 	zfree(pn, sizeof(struct process));
     }
 
+    pn = jn->auxprocs;
+    jn->auxprocs = NULL;
+    for (; pn; pn = nx) {
+	nx = pn->next;
+	zfree(pn, sizeof(struct process));
+    }
+
     if (jn->ty)
 	zfree(jn->ty, sizeof(struct ttyinfo));
     if (jn->pwd)
@@ -819,7 +844,6 @@
     }
     jn->gleader = jn->other = 0;
     jn->stat = jn->stty_in_env = 0;
-    jn->procs = NULL;
     jn->filelist = NULL;
     jn->ty = NULL;
 }
@@ -842,13 +866,19 @@
     freejob(jn, 1);
 }
 
-/* add a process to the current job */
+/*
+ * Add a process to the current job.
+ * The third argument is 1 if we are adding a process which is not
+ * part of the main pipeline but an auxiliary process used for
+ * handling MULTIOS or process substitution.  We will wait for it
+ * but not display job information about it.
+ */
 
 /**/
 void
-addproc(pid_t pid, char *text)
+addproc(pid_t pid, char *text, int aux)
 {
-    Process pn;
+    Process pn, *pnlist;
     struct timezone dummy_tz;
 
     pn = (Process) zcalloc(sizeof *pn);
@@ -857,25 +887,30 @@
 	strcpy(pn->text, text);
     else
 	*pn->text = '\0';
-    gettimeofday(&pn->bgtime, &dummy_tz);
     pn->status = SP_RUNNING;
     pn->next = NULL;
 
-    /* if this is the first process we are adding to *
-     * the job, then it's the group leader.          */
-    if (!jobtab[thisjob].gleader)
-	jobtab[thisjob].gleader = pid;
+    if (!aux)
+    {
+	gettimeofday(&pn->bgtime, &dummy_tz);
+	/* if this is the first process we are adding to *
+	 * the job, then it's the group leader.          */
+	if (!jobtab[thisjob].gleader)
+	    jobtab[thisjob].gleader = pid;
+	/* attach this process to end of process list of current job */
+	pnlist = &jobtab[thisjob].procs;
+    }
+    else
+	pnlist = &jobtab[thisjob].auxprocs;
 
-    /* attach this process to end of process list of current job */
-    if (jobtab[thisjob].procs) {
+    if (*pnlist) {
 	Process n;
 
-	for (n = jobtab[thisjob].procs; n->next; n = n->next);
-	pn->next = NULL;
+	for (n = *pnlist; n->next; n = n->next);
 	n->next = pn;
     } else {
 	/* first process for this job */
-	jobtab[thisjob].procs = pn;
+	*pnlist = pn;
     }
     /* If the first process in the job finished before any others were *
      * added, maybe STAT_DONE got set incorrectly.  This can happen if *
@@ -938,7 +973,7 @@
 
     dont_queue_signals();
     child_block();		 /* unblocked during child_suspend() */
-    if (jn->procs) {		 /* if any forks were done         */
+    if (jn->procs || jn->auxprocs) { /* if any forks were done         */
 	jn->stat |= STAT_LOCKED;
 	if (jn->stat & STAT_CHANGED)
 	    printjob(jn, !!isset(LONGLISTJOBS), 1);
@@ -978,7 +1013,7 @@
 {
     Job jn = jobtab + thisjob;
 
-    if (jn->procs)
+    if (jn->procs || jn->auxprocs)
 	zwaitjob(thisjob, 0);
     else {
 	deletejob(jn);
@@ -1075,7 +1110,7 @@
 	    fflush(stderr);
 	}
     }
-    if (!jobtab[thisjob].procs)
+    if (!hasprocs(thisjob))
 	deletejob(jobtab + thisjob);
     else
 	jobtab[thisjob].stat |= STAT_LOCKED;
@@ -1373,7 +1408,7 @@
 	    Job j;
 	    Process p;
 
-	    if (findproc(pid, &j, &p))
+	    if (findproc(pid, &j, &p, 0))
 		waitforpid(pid);
 	    else
 		zwarnnam(name, "pid %d is not a child of this shell", 0, pid);
Index: Src/signals.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/signals.c,v
retrieving revision 1.21
diff -u -r1.21 signals.c
--- Src/signals.c	29 May 2002 14:28:14 -0000	1.21
+++ Src/signals.c	30 Apr 2003 20:01:50 -0000
@@ -487,8 +487,11 @@
             }
 
 	    /* Find the process and job containing this pid and update it. */
-	    if (findproc(pid, &jn, &pn)) {
+	    if (findproc(pid, &jn, &pn, 0)) {
 		update_process(pn, status);
+		update_job(jn);
+	    } else if (findproc(pid, &jn, &pn, 1)) {
+		pn->status = status;
 		update_job(jn);
 	    } else {
 		/* If not found, update the shell record of time spent by
Index: Src/zsh.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/zsh.h,v
retrieving revision 1.45
diff -u -r1.45 zsh.h
--- Src/zsh.h	25 Apr 2003 11:19:10 -0000	1.45
+++ Src/zsh.h	30 Apr 2003 20:01:57 -0000
@@ -697,6 +697,7 @@
     char *pwd;			/* current working dir of shell when *
 				 * this job was spawned              */
     struct process *procs;	/* list of processes                 */
+    struct process *auxprocs;	/* auxiliary processes e.g multios   */
     LinkList filelist;		/* list of files to delete when done */
     int stty_in_env;		/* if STTY=... is present            */
     struct ttyinfo *ty;		/* the modes specified by STTY       */
Index: Test/A04redirect.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/A04redirect.ztst,v
retrieving revision 1.3
diff -u -r1.3 A04redirect.ztst
--- Test/A04redirect.ztst	9 Jul 2001 18:31:25 -0000	1.3
+++ Test/A04redirect.ztst	30 Apr 2003 20:01:57 -0000
@@ -137,16 +137,10 @@
 >errout:
 >Output
 
-# Following two tests have to be separated since in
-#   print bar >foo >bar && print "$(<foo) $(<bar)"
-# the multios aren't flushed until after the substitutions take
-# place.  This can't be right.
   rm -f errout
   print doo be doo be doo >foo >bar 
-0:setup 2-file multio
-
   print "foo: $(<foo)\nbar: $(<bar)"
-0:read 2-file multio
+0:2-file multio
 >foo: doo be doo be doo
 >bar: doo be doo be doo
 
@@ -162,11 +156,9 @@
   rm -f *
   touch out1 out2
   print All files >*
-0:setup multio with globbing
-
   print *
   print "out1: $(<out1)\nout2: $(<out2)"
-0:read multio with globbing
+0:multio with globbing
 >out1 out2
 >out1: All files
 >out2: All files
Index: Test/D03procsubst.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/D03procsubst.ztst,v
retrieving revision 1.2
diff -u -r1.2 D03procsubst.ztst
--- Test/D03procsubst.ztst	26 Jun 2001 15:02:34 -0000	1.2
+++ Test/D03procsubst.ztst	30 Apr 2003 20:01:57 -0000
@@ -17,8 +17,8 @@
 0:<(...) substitution
 >First	Dritte
 
-  paste <(cut -f2 FILE1) <(cut -f4 FILE2) > >(sed 's/e/E/g' >OUTFILE)
-  sleep 1	# since the sed is asynchronous
+# slightly desperate hack to force >(...) to be synchronous
+  { paste <(cut -f2 FILE1) <(cut -f4 FILE2) } > >(sed 's/e/E/g' >OUTFILE)
   cat OUTFILE
 0:>(...) substitution
 >SEcond	ViErtE

-- 
Peter Stephenson <pws@pwstephenson.fsnet.co.uk>
Work: pws@csr.com
Web: http://www.pwstephenson.fsnet.co.uk


^ permalink raw reply	[flat|nested] 5+ messages in thread

* PATCH: tidy up for test-2
  2003-04-30 19:08     ` PATCH: wait for auxiliary processes Peter Stephenson
@ 2003-05-02 10:31       ` Peter Stephenson
  0 siblings, 0 replies; 5+ messages in thread
From: Peter Stephenson @ 2003-05-02 10:31 UTC (permalink / raw)
  To: zsh-workers

Peter Stephenson wrote:
> Peter Stephenson wrote:
> > > # Following two tests have to be separated since in
> > > #   print bar >foo >bar && print "$(<foo) $(<bar)"
> > > # the multios aren't flushed until after the substitutions take
> > > # place.  This can't be right.
> > 
> > I can partially fix this by storing a list of auxiliary processes
> > for which the job should wait.

This is now committed with some typos in the documentation fixed.

Here are some minor things I've been collecting but haven't bothered to
post separately.

I will make a test-2 either today or next week (but not Monday which is
a bank holiday).

Index: README
===================================================================
RCS file: /cvsroot/zsh/zsh/README,v
retrieving revision 1.10
diff -u -r1.10 README
--- README	4 Apr 2003 13:22:57 -0000	1.10
+++ README	2 May 2003 10:26:36 -0000
@@ -35,6 +35,10 @@
   autoload -U select-word-style
   select-word-style bash
 
+The `=prog' facility for expanding command paths (provided the EQUALS
+option is enabled, as it is by default) no longer expands aliases.  It was
+felt this feature was underused and confusing.
+
 Documentation
 -------------
 
Index: Etc/NEWS
===================================================================
RCS file: /cvsroot/zsh/zsh/Etc/NEWS,v
retrieving revision 1.9
diff -u -r1.9 NEWS
--- Etc/NEWS	4 Apr 2003 14:20:17 -0000	1.9
+++ Etc/NEWS	2 May 2003 10:26:36 -0000
@@ -51,13 +51,14 @@
 - supplied highly configurable word widgets forward-word-match etc., can
   set what constitutes a word interactively or in startup script
   (implement bash-style behaviour, replacing previous bash-* word widgets)
-- interface to increment search via $LASTSEARCH
+- interface to incremental search via $LASTSEARCH
 - better handling of keymaps in zle and widgets
 - better support for output from user-defined widgets while zle is active
 - tetris game which runs entirely in zle
 
 Local internal improvements:
 - disowned jobs are automatically restarted
+- \u and \U print escapes for Unicode
 - line numbers in error messages and $PS4 output are more consistent
 - `=prog' expands only paths, no longer aliases for consistency
 - job display in prompts; `jobs' command output can be piped
@@ -65,7 +66,7 @@
 - rand48() function for better randomness in arithmetic
   (if the corresponding math library function is present)
 - $SECONDS parameter can be made floating point via `typeset -F SECONDS'
-  for better accuracy
+  for better timing accuracy
 - improvements to command line history mechanism
 - many bugfixes
 
Index: Functions/TCP/tcp_spam
===================================================================
RCS file: /cvsroot/zsh/zsh/Functions/TCP/tcp_spam,v
retrieving revision 1.3
diff -u -r1.3 tcp_spam
--- Functions/TCP/tcp_spam	3 Apr 2003 10:24:55 -0000	1.3
+++ Functions/TCP/tcp_spam	2 May 2003 10:26:36 -0000
@@ -95,7 +95,7 @@
     tcp_on_spam $TCP_SESS $cmd $*
     [[ $REPLY = done ]] && continue
   fi
-  [[ -n $verbose ]] && zformat REPLY $TCP_PROMPT "s:$TCP_SESS" \
-    "f:${tcp_by_name[$TCP_SESS]}"
+  [[ -n $verbose ]] && zformat -f REPLY $TCP_PROMPT "s:$TCP_SESS" \
+    "f:${tcp_by_name[$TCP_SESS]}" && print -r $REPLY
   eval $cmd '$*'
 done

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-05-02 10:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-23 15:15 Y03arguments.ztst fails Peter Whaite
2003-04-25 10:42 ` Peter Stephenson
2003-04-26 19:27   ` Peter Stephenson
2003-04-30 19:08     ` PATCH: wait for auxiliary processes Peter Stephenson
2003-05-02 10:31       ` PATCH: tidy up for test-2 Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).