fd(4)


fd -- file descriptor files

Synopsis

   /dev/fd/*

Description

These files, conventionally called /dev/fd/0, /dev/fd/1, /dev/fd/2, and so on, refer to files accessible through file descriptors. If file descriptor n is open, these two system calls have the same effect:
   fd = open("/dev/fd/n",mode);
   fd = dup(n);

On these files creat(2) is equivalent to open, and the read and write bits are ignored and O_TRUNC is failed with ENOSYS. As with dup, subsequent reads or writes on fd fail unless the original file descriptor allows the operations.

For convenience in referring to standard input, standard output, and standard error, an additional set of names is provided: /dev/stdin is a synonym for /dev/fd/0, /dev/stdout for /dev/fd/1, and /dev/stderr for /dev/fd/2.

References

access(2), dup(2), ls(1) open(2), stat(2)

Notices

open(2) returns -1 and EBADF if the associated file descriptor is not open. However, if the truncation is specified in the call to open, then ENOSYS is returned. If a file is open for reading, an attempt to reopen it for writing will fail; instead a new file descriptor (read-only) is created.

access(2) always returns with success. stat(2) returns a reasonable value for /dev/fd itself, but when called for files in /dev/fd, the attributes for those ``files'' are faked. Note also that using ls(1) on /dev/fd always lists nf files, where nf is the user's current soft limit for open files, and not only those the user has opened.


© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004