xref: /csrg-svn/share/man/man4/fd.4 (revision 63002)
1*63002Sbostic.\" Copyright (c) 1990, 1991, 1993
2*63002Sbostic.\"	The Regents of the University of California.  All rights reserved.
341534Sbostic.\"
441534Sbostic.\" %sccs.include.redist.man%
541534Sbostic.\"
6*63002Sbostic.\"     @(#)fd.4	8.1 (Berkeley) 06/09/93
741534Sbostic.\"
847675Scael.Dd
947675Scael.Dt FD 4
1047675Scael.Os
1147675Scael.Sh NAME
1247675Scael.Nm fd ,
1347675Scael.Nm stdin ,
1447675Scael.Nm stdout ,
1547675Scael.Nm stderr
1647675Scael.Nd file descriptor files
1747675Scael.Sh DESCRIPTION
1841534SbosticThe files
1947675Scael.Pa /dev/fd/0
2041534Sbosticthrough
2147675Scael.Pa /dev/fd/#
2241534Sbosticrefer to file descriptors which can be accessed through the file
2341534Sbosticsystem.
2441534SbosticIf the file descriptor is open and the mode the file is being opened
2541534Sbosticwith is a subset of the mode of the existing descriptor, the call:
2647675Scael.Bd -literal -offset indent
2741534Sbosticfd = open("/dev/fd/0", mode);
2847675Scael.Ed
2947675Scael.Pp
3041534Sbosticand the call:
3147675Scael.Bd -literal -offset indent
3241534Sbosticfd = fcntl(0, F_DUPFD, 0);
3347675Scael.Ed
3447675Scael.Pp
3541534Sbosticare equivalent.
3647675Scael.Pp
3741534SbosticOpening the files
3847675Scael.Pa /dev/stdin ,
3947675Scael.Pa /dev/stdout
4041534Sbosticand
4147675Scael.Pa /dev/stderr
4241534Sbosticis equivalent to the following calls:
4347675Scael.Bd -literal -offset indent
4441534Sbosticfd = fcntl(STDIN_FILENO,  F_DUPFD, 0);
4541534Sbosticfd = fcntl(STDOUT_FILENO, F_DUPFD, 0);
4641534Sbosticfd = fcntl(STDERR_FILENO, F_DUPFD, 0);
4747675Scael.Ed
4847675Scael.Pp
4941534SbosticFlags to the
5047675Scael.Xr open 2
5147675Scaelcall other than
5247675Scael.Dv O_RDONLY ,
5347675Scael.Dv O_WRONLY
5447675Scaeland
5547675Scael.Dv O_RDWR
5647675Scaelare ignored.
5747675Scael.Sh FILES
5847675Scael.Bl -tag -width /dev/stderr -compact
5947675Scael.It Pa /dev/fd/#
6047675Scael.It Pa /dev/stdin
6147675Scael.It Pa /dev/stdout
6247675Scael.It Pa /dev/stderr
6347675Scael.El
6447675Scael.Sh SEE ALSO
6547675Scael.Xr tty 4
66