Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: multios and unnecessary processes
- X-seq: zsh-workers 20666
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxxxxx>
- Subject: Re: multios and unnecessary processes
- Date: Mon, 10 Jan 2005 19:20:41 +0000
- In-reply-to: <20050110171101.GD4432@sc>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20050109164753.GA4246@sc> <1050109203218.ZM22780@xxxxxxxxxxxxxxxxxxxxxxx> <20050110094918.GA4432@sc> <1050110165325.ZM26928@xxxxxxxxxxxxxxxxxxxxxxx> <20050110171101.GD4432@sc>
On Jan 10, 5:11pm, Stephane Chazelas wrote:
} Subject: Re: multios and unnecessary processes
}
} However to get back to my initial statement, don't you agree
} it's a problem that
}
} cmd >&2 >&- >&2
}
} doesn't redirect stdout to stderr but to a pipe to a background
} process that just echos the output to stderr?
Yes, that could be considered a bug. Suggested patch below.
But under what circumstances would you write that?
The only case where I can think offhand of that coming up is something
like this:
original_cmd="lsof -ag $$ -d 0-2,10-15 >&2"
# ... time and code passes ...
modified_cmd="$original_cmd >&-"
# ... more time and code passes ...
finished_cmd="$modified_cmd >&2"
eval $finished_cmd
Here's the patch. This relies on the fact that mfds[] elements are heap
allocated; it also means that repeatedly opening and closing a descriptor
with MULTIOS on will repeatedly allocate and discard a multio structure,
whereas before it would re-use it even after closing.
Patch line numbers may be off because I've applied 20632 (PWS, I think
you could commit that, it seems to be fine).
Index: Src/exec.c
===================================================================
RCS file: /extra/cvsroot/zsh/zsh-4.0/Src/exec.c,v
retrieving revision 1.22
diff -c -r1.22 exec.c
--- exec.c 6 Dec 2004 16:51:18 -0000 1.22
+++ exec.c 10 Jan 2005 19:08:51 -0000
@@ -1487,6 +1488,7 @@
}
_exit(0);
}
+ mfds[fd] = NULL;
}
/* close all the mnodes (failure) */
Messages sorted by:
Reverse Date,
Date,
Thread,
Author