GNU bug report logs -
#6900
mktemp: want option to make a fifo
Previous Next
Reported by: John Reiser <jreiser <at> bitwagon.com>
Date: Mon, 23 Aug 2010 15:41:01 UTC
Severity: normal
Tags: notabug
Merged with 6330
Done: Jim Meyering <jim <at> meyering.net>
Bug is archived. No further changes may be made.
Full log
Message #56 received at 6900 <at> debbugs.gnu.org (full text, mbox):
On 08/24/2010 11:32 AM, Paul Eggert wrote:
> dir=$(mktemp -d dir.XXXXXX)
> mkfifo $dir/1 $dir/2
> listener1 < $dir/1
> listener2 < $dir/2
> cmd1 2> $dir/1 | cmd2 2> $dir/2
> Better yet, do not use named fifos, since pipes suffice:
>
> (cmd1 2>&1 >&3 | listener1) 3>&1 |
> (cmd2 2>&1 >&3 | listener2) 3>&1
That is not equivalent! stdout from listener1 gets piped into
cmd2, instead of going to the common stdout of all processes
other than cmd1. Fixing this using only anonymous pipes
is cumbersome because the additional file descriptor must be
[should be] redirected by all four processes.
Also, file descriptor 3 is left open in all processes, which
hogs system resources and is less safe.
Therefore something like this is required:
4>&1 (
3>&1 ( 1>&3 2>&1 3>&- 4>&- cmd1
| 1>&4 3>&- 4>&- listener1
)
|
3>&1 4>&- ( 1>&3 2>&1 3>&- cmd2
| 3>&- listener2
)
)
where the formatting emphasizes prefix actions and common elements.
Using the named fifos is much more readable and understandable.
The cost is explicit cleanup, including the transfer of the onus
for recovery at resource exhaustion (fd not available, space
not available in filesystem) from the shell to the user.
--
This bug report was last modified 13 years and 350 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.