LinuxSA Mailing list archives
Index:
[thread]
[date]
[subject]
[author]
From: Jake Hawkes <jake@infinitylimited.net>
To : Daryl Tester <dt@picknowl.com.au>
Date: Fri, 28 Apr 2000 09:12:52 +0930
Re: Protecting files against power failure
Daryl Tester wrote:
>
> Jake Hawkes wrote:
>
> >>> exec 5>foo 6<foo
>
> > ok, I grok this, but why does it work when executed one by one at the
> > prompt? In a shell script - sure, but at the prompt?
>
> Same reason for both - the "exec 5>foo 6<foo" applies to the _current_
> shell. When you execute "cat <&6", the shell is actually duplicating
> file descriptor #6 onto #0 (standard input), because that's what <&6
> means. cat then reads to EOF on its standard input, then returns.
> Upon returns, file descriptor 6 is at the end of file mark. You could
> even do something like ...
>
> exec 5<foo 6>foo
> rm foo
> echo "hi" >&5
> cat <&6
> echo "there" >&5
> cat <&6
> # etc.
>
> to your little heart's content. I suspect that if you could pass
> this descriptor into your favourite programming/scripting language,
> you could even rewind it back to the beginning of the non-existant
> file and replay its contents (although, of course, this shouldn't
> affect the shell's file descriptor - care to hazard a guess why?).
this feels like a class :) Bueler... Bueler....
um, because the file descriptors are passed by value, not reference?
--
Jake Hawkes, B.Eng (CSE)
"I'm only smart enough to know how stupid I am", Joe Strummer.
--
LinuxSA WWW: http://www.linuxsa.org.au/ IRC: #linuxsa on irc.linux.org.au
To unsubscribe from the LinuxSA list:
mail linuxsa-request@linuxsa.org.au with "unsubscribe" as the subject
Index:
[thread]
[date]
[subject]
[author]
Return to the LinuxSA Mailing List Information Page