[Wylug-help] Scriptable FTP, creating remote archives
Aaron Crane
wylug at aaroncrane.co.uk
Mon Dec 5 14:50:25 UTC 2011
John Hodrien <J.H.Hodrien at leeds.ac.uk> wrote:
> On Fri, 2 Dec 2011, Smylers wrote:
>> Is it an old-style proper Unix feature that's been around for decades
>> without me noticing it?
Well, it's certainly an old-style proper Unix feature that's been
around for decades…
>> Where's it documented?
That's an excellent point. I believe it should be in stdin(4),
stdout(4), stderr(4), fd(4) (and all of those should actually be the
same document), but the current Linux manpages don't seem to include
any of those. There's a brief mention in proc(5), but that's not
exactly obvious — you'd need to poke around enough to work out that
/dev/stdin is symlink-equivalent to /dev/fd/0 and therefore to
/proc/self/fd/0, and that /proc is documented in proc(5).
>> (I see it's mentioned in
>> bash(1), so I really should've known about it, but that can't be its
>> canonical docs.)
The Bash source provides a partial reimplementation of /dev/stdin and
friends, for the benefit of ancient systems that don't implement them
in kernel space. (It makes them work as redirection targets, and I
think the builtin equivalent of test(1) special-cases them too.) So
that's why bash(1) mentions them.
But I wouldn't expect any Bash binaries built for Linux to incorporate
that code (and certainly not the Bash in a modern Linux distribution).
And your question about the location of the canonical documentation
still stands.
> That's a good question, and I'm not sure about the answer to be honest. Some
> things seem to suggest it's not universally present and the appeared in linux
> first,
It definitely predates Linux. Relevant manpages for 4.3BSD Reno
(dated May 1990) and Solaris 2.5 / SunOS 5.5 (dated July 1990):
http://www.freebsd.org/cgi/man.cgi?query=fd&sektion=4&manpath=4.3BSD+Reno
http://www.freebsd.org/cgi/man.cgi?query=fd&sektion=4&manpath=SunOS+5.5.1
> and it appears to behave slightly differently on different OSs.
Specifically: the BSD approach is that opening /dev/fd/N for some
non-negative integer N is identical to calling dup(2) with N as its
argument; that gives you a file descriptor which shares its file
offset pointer with the opening process's existing file descriptor N.
On Linux, on the other hand, opening /dev/fd/N gives you a new,
independent file descriptor, open on the same file.
--
Aaron Crane ** http://aaroncrane.co.uk/
More information about the Wylug-help
mailing list