Re: zeroseek and qmail
"Mark Delany" <[email protected]> 27 Aug 2002 19:12:35 +0000
| Newsgroups | gmane.comp.djb.zeroseek |
|---|---|
| Message-ID | <[email protected]> |
On Tue, Aug 27, 2002 at 02:28:26PM -0400, Russell Nelson allegedly wrote:
> Mark Delany writes:
> > Strictly speaking, it doesn't follow that the fd that qmail-local
> > gives to the delivery command has to likewise be seeakable, but in
> > practice that's the expectation the author has as we see in things
> > like condredirect.
>
> Unless it's in the documentation, we must treat it as a detail of the
> implementation. Just because Dan feels free to use that detail in his
> set of programs, that doesn't mean that we should feel equally free.
I was going to say that a new delivery instruction, say, '>' could
signify a seekable pipeline, but it's such a trivial thing to do in
.qmail space that you wouldn't bother, eg:
| make-seekable-pipe my-command my-params
Where:
cat <<EOD >make-seekable-pipe
#! /bin/sh
set -e
# The risk to using /tmp out-weighs the auto-cleanup bennies so we do
# it ourselves by minimizing the window in which the filename exists
# in the home dir. Any failure after the rm means that the file is not
# left around.
tmp=seekable.$$
exec 3<&0 4<&1 >$tmp <$tmp
rm $tmp
cat <&3 # Create the seekable file
# Recover stdout, close holding fds and start the real command. Note
# that stdin is already opened to the tmp file.
exec ${1+"$@"} 1<&4 3>&- 4>&-
EOD
Regards.