From 94da86f7956af9d6855c12d79d757b961bf0c2a4 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Fri, 2 May 2003 10:25:27 +0000 Subject: 18492: Provide partial fix for multios and output process substitution asynchronicity problem. Document workarounds for remaining problems. --- Doc/Zsh/expn.yo | 36 +++++++++++++++++++++++++++++------- Doc/Zsh/redirect.yo | 22 ++++++++++++++++++++++ 2 files changed, 51 insertions(+), 7 deletions(-) (limited to 'Doc') diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo index cf5f98f9e..d4d509e47 100644 --- a/Doc/Zsh/expn.yo +++ b/Doc/Zsh/expn.yo @@ -332,7 +332,16 @@ cuts fields 1 and 3 from the files var(file1) and var(file2) respectively, 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(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())var(process)tt(RPAR())) + +(note that no tt(MULTIOS) are involved), var(process) will be run +asynchronously. The workaround is: + +example(tt({ paste >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) diff --git a/Doc/Zsh/redirect.yo b/Doc/Zsh/redirect.yo index a8c2b907c..2e48aa7ab 100644 --- a/Doc/Zsh/redirect.yo +++ b/Doc/Zsh/redirect.yo @@ -209,6 +209,28 @@ example(echo foo > bar > baz) 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 after 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 -- cgit 1.4.1