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 97 98 99 100
|
.\" Hey Emacs! This file is -*- nroff -*- source.
.\"
.\" 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.
.\"
.\" Traduction 9/10/1996 par Christophe Blaess (ccb@club-internet.fr)
.\"
.TH DUP 2 "9 Octobre 1996" "Linux 1.1.46" "Manuel du programmeur Linux"
.SH NOM
dup, dup2 \- Dupliquer un descripteur de fichier.
.SH SYNOPSIS
.nf
.B #include <unistd.h>
.sp
.BI "int dup(int " oldfd );
.BI "int dup2(int " oldfd ", int " newfd );
.fi
.SH DESCRIPTION
.BR dup " et " dup2
crent une copie du descripteur de fichier
.IR oldfd .
L'ancien et le nouveau descripteurs peuvent tre utiliss de manire
interchangeable. Ils partagent les verrous, les pointeurs de position
et les drapeaux. Par exemple si le pointeur de position est modifi en
utilisant
.B lseek
sur l'un des descripteurs, la position est galement change pour l'autre.
Les deux descripteurs ne partagent toutefois pas le drapeau Close-on-exec.
.B dup
utilise le plus petit numro inutilis pour le nouveau
descripteur.
.B dup2
.RI "transforme " newfd " en une copie de " oldfd ", fermant auparavant " newfd
si besoin est.
.SH "VALEUR RENVOYE"
.BR dup " et " dup2
renvoient le nouveau descripteur, ou \-1 s'ils chouent, auquel
cas
.I errno
contient le code d'erreur.
.SH ERREURS
.TP
.B EBADF
.I oldfd
n'est pas un descripteur valide, ou
.I newfd
n'est pas dans les valeurs autorises pour un descripteur.
.TP
.B EMFILE
Le processus dispose dj du nombre maximum de descripteurs de fichiers
autoriss simultanment, et tente d'en ouvrir un nouveau.
.SH ATTENTION
Les erreurs renvoyes par
.B dup2
sont diffrentes de celles retournes par
.BR fcntl( ..., F_DUPFD ,... )
si
.I newfd
n'est pas dans les valeurs autorises. Sur certains systmes
.B dup2
retourne aussi parfois
.B EINVAL
comme
.BR F_DUPFD .
.SH "CONFORMIT"
SVr4, SVID POSIX, X/OPEN, BSD 4.3. SVr4 documente des conditions d'erreur
supplmentaires EINTR et ENOLINK. POSIX.1 ajoute galement EINTR.
.SH "VOIR AUSSI"
.BR " fcntl "(2), " open "(2), " close "(2).
.SH TRADUCTION
Christophe Blaess, 1997.
|