1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
.\" -*- nroff -*-
.\"
.\" This manpage is Copyright (C) 1992 Drew Eckhardt;
.\" 1993 Michael Haardt, Ian Jackson.
.\"
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Permission is granted to copy and distribute modified versions of this
.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one
.\"
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date. The author(s) assume no
.\" responsibility for errors or omissions, or for damages resulting from
.\" the use of the information contained herein. The author(s) may not
.\" have taken the same level of care in the production of this manual,
.\" which is licensed free of charge, as they might when working
.\" professionally.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\"
.\" Modified Wed Jul 21 22:45:39 1993 by Rik Faith <faith@cs.unc.edu>
.\" Modified 21 Aug 1994 by Michael Chastain <mec@shell.portal.com>:
.\" Fixed typoes.
.\" Modified Fri Jan 31 16:23:46 1997 by Eric S. Raymond <esr@thyrsus.com>
.\"
.TH DUP 2 "21/08/1994" "Linux 1.1.46" "Manual do Programador Linux"
.SH NOME
dup, dup2 \- duplica um descritor de arquivos
.SH SINOPSE
.nf
.B #include <unistd.h>
.sp
.BI "int dup(int " oldfd );
.BI "int dup2(int " oldfd ", int " newfd );
.fi
.SH DESCRIO
.BR dup " e " dup2
criam uma cpia do descritor de arquivos
.IR oldfd .
Depois do retorno bem sucedido de \fBdup\fR ou \fBdup2\fR,
o velho e o novo descritores podem ser usados sem distino. Eles compartilham
travamento, posicionamento do arquivo, ponteiros e sinalizadores; por exemplo, se a posio do
arquivo modificada usando-se
.B lseek
em um dos descritores, a posio , tambm, alterada para o outro.
De qualquer forma, Os dois descritores no dividem o sinalizador close-on-exec.
.B dup
usa o mais baixo nmero no usado de descritor para o novo descritor.
.B dup2
.RI "makes " newfd " ser a cpia de " oldfd ", closing " newfd
primeiro se necesrio.
.SH "VALORES RETORNADOS"
.BR dup " e " dup2
retorna o novo descritor, ou \-1 se um erro occurrido (neste caso,
.I errno
selecionado adequadamente).
.SH ERROS
.TP
.B EBADF
.I oldfd
no um descritor de arquivo aberto, ou
.I newfd
est fora do intervalo permitido para descritores de arquivos.
.TP
.B EMFILE
O processo tem um nmero mximo de descritores de arquivos
abertos e tenta abrir um novo.
.SH ADVERTNCIA
O erro retornado por
.B dup2
diferente que aquele retornado por
.BR fcntl( "..., " F_DUPFD ", ..." )
quando
.I newfd
est fora do intervalo. Em muitos sistemas
.B dup2
tambm retorna s vezes
.B EINVAL
como
.BR F_DUPFD .
.SH "DE ACORDO COM"
SVr4, SVID, POSIX, X/OPEN, BSD 4.3. SVr4 documenta condies de erros
adicionais EINTR e ENOLINK. POSIX.1 adiciona EINTR.
.SH "VEJA TAMBM"
.BR fcntl (2),
.BR open (2),
.BR close (2)
|