File: dup.2

package info (click to toggle)
manpages-es 0.4a-2
  • links: PTS
  • area: main
  • in suites: hamm, slink
  • size: 3,592 kB
  • ctags: 3
  • sloc: sh: 59; makefile: 42
file content (96 lines) | stat: -rw-r--r-- 3,281 bytes parent folder | download
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
.\" 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.
.\" Translated 1 Jul 1996 Miguel A. Sepulveda (angel@vivaldi.princeton.edu)
.\" Updated 8 Jul 1997 Nicols Lichtmaier <nick@debian.org>
.TH DUP 2 "1 Julio 1996" "Linux 1.1.46" "Manual del Programador Linux"
.SH NOMBRE
dup, dup2 \- duplica un descriptor de fichero
.SH SINOPSIS
.nf
.B #include <unistd.h>
.sp
.BI "int dup(int " oldfd );
.BI "int dup2(int " oldfd ", int " newfd );
.fi
.SH DESCRIPCIN
.BR dup " y " dup2
crean una copia del descriptor de fichero
.IR oldfd .

Los descriptores antiguo y nuevo pueden usarse indiferentemente. Comparten
candados (locks), punteros de posicin de fichero y banderas (flags);
por ejemplo, si la posicin del fichero se modifica usando
.B lseek
en uno de los descriptores, la posicin en el otro tambin cambia.     

Sin embargo los descriptores no comparten la bandera close-on-exec,
(cierra-en-ejecucin).

.B dup
usa el valor ms bajo disponible para el nuevo
descriptor.

.B dup2
.RI "hace que " newfd " sea la copia de " oldfd ", cerrando primero " newfd
si es necesario.
.SH "VALOR REGRESADO"
.BR dup " y " dup2
regresa el valor del nuevo descriptor, o \-1 si ocurre algn error, en 
dicho caso 
.I errno
se asigna apropiadamente.
.SH ERRORES
.TP
.B EBADF
.I oldfd
no es un descriptor de fichero abierto, o
.I newfd
est fuera del rango permitido para descriptores de ficheros.
.TP
.B EMFILE
El proceso ya tiene el mximo nmero de descriptores de fichero
abiertos y se ha intentado abrir uno nuevo. 
.SH ADVERTENCIA 
El error regresado por
.B dup2
es diferente de aquel regresado por
.BR fcntl( ..., F_DUPFD ,... )
cuando
.I newfd
est fuera de rango. En algunos sistemas
.B dup2
a veces regresa          
.B EINVAL
como
.BR F_DUPFD .
.SH "CONFORMA CON"
SVr4, SVID, POSIX, X/OPEN, BSD 4.3. SVr4 documenta las condiciones de error
adicionales EINTR y ENOLINK.  POSIX.1 aade EINTR.
.SH "VASE TAMBIN"
.BR " fcntl "(2), " open "(2), " close "(2).