zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: Zsh workers <zsh-workers@sunsite.dk>
Subject: Re: $pipestatus broken
Date: Mon, 03 Nov 2003 11:24:21 +0000	[thread overview]
Message-ID: <22349.1067858661@csr.com> (raw)
In-Reply-To: "Bart Schaefer"'s message of "Mon, 03 Nov 2003 01:55:38 GMT." <1031103015538.ZM607@candle.brasslantern.com>

Bart Schaefer wrote:
> I think there's code to save and restore `lastval' around precmd(), but
> it doesn't save and restore the entire `pipestats' array.

It's in doshfunc.  It would be more efficient to save in restore in
preprompt(), but at the expense of extra code.

I think the first chunk is some debugging code which should have been
deleted.  I can guess who put that there.

There still doesn't seem to be a dupmem function...

Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.54
diff -u -r1.54 exec.c
--- Src/exec.c	29 Oct 2003 19:17:30 -0000	1.54
+++ Src/exec.c	3 Nov 2003 11:18:23 -0000
@@ -3064,8 +3064,6 @@
 	if (!out)
 	{
 	    addproc(pid, NULL, 1);
-	    fprintf(stderr, "Proc %d added\n", pid);
-	    fflush(stderr);
 	}
 	return pnam;
     }
@@ -3448,7 +3446,8 @@
  * was executed.                                            */
 {
     char **tab, **x, *oargv0;
-    int oldzoptind, oldlastval, oldoptcind;
+    int oldzoptind, oldlastval, oldoptcind, oldnumpipestats;
+    int *oldpipestats = NULL;
     char saveopts[OPT_SIZE], *oldscriptname = scriptname, *fname = dupstring(name);
     int obreaks;
     struct funcstack fstack;
@@ -3463,6 +3462,16 @@
     if (trapreturn < 0)
 	trapreturn--;
     oldlastval = lastval;
+    oldnumpipestats = numpipestats;
+    if (noreturnval) {
+	/*
+	 * Easiest to use the heap here since we're bracketed
+	 * immediately by a pushheap/popheap pair.
+	 */
+	size_t bytes = sizeof(int)*numpipestats;
+	oldpipestats = (int *)zhalloc(bytes);
+	memcpy(oldpipestats, pipestats, bytes);
+    }
 
     starttrapscope();
 
@@ -3568,8 +3577,11 @@
 
     if (trapreturn < -1)
 	trapreturn++;
-    if (noreturnval)
+    if (noreturnval) {
 	lastval = oldlastval;
+	numpipestats = oldnumpipestats;
+	memcpy(pipestats, oldpipestats, sizeof(int)*numpipestats);
+    }
     popheap();
 
     if (exit_pending) {



-- 
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.
**********************************************************************


  reply	other threads:[~2003-11-03 11:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-02 11:23 Oliver Kiddle
2003-11-03  1:55 ` Bart Schaefer
2003-11-03 11:24   ` Peter Stephenson [this message]
2003-11-03 12:56   ` Oliver Kiddle
2003-11-03 13:04     ` Peter Stephenson
2003-11-03 13:35       ` Oliver Kiddle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=22349.1067858661@csr.com \
    --to=pws@csr.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).