.\" 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. .\" German translation 1 Feb 1996 Aldo Valente (aldo@dagobar.rhein.de) .\" .TH DUP 2 "21. August 1994" "Linux 1.1.46" "Linux Systemaufrufe" .SH BEZEICHNUNG dup, dup2 \- dupliziert einen file descriptor (Datei-Referenz) .SH SYNOPSIS .nf .B #include .sp .BI "int dup(int " oldfd ); .BI "int dup2(int " oldfd ", int " newfd ); .fi .SH BESCHREIBUNG .BR dup " und " dup2 erzeugen eine Kopie des file descriptor .IR oldfd . Die alten und neuen Deskriptoren können wahlfrei benutzt werden. Sie teilen sich Locks, Dateipositionszeiger (File Position Pointers) und Flags; falls beispielsweise die Dateiposition durch .B lseek für einen der Deskriptoren verändert wurde, ist es sie auch für den anderen. Die close-on-exec flag (Schließen-bei-Ausführung) teilen sie sich jedoch nicht. .B dup benutzt den unbenutzten Deskriptor mit der kleinsten Nummer für den neuen. .B dup2 .RI "macht " newfd " zur Kopie von " oldfd ", wobei " newfd , falls notwendig, zuerst geschlossen wird. .SH "WIEDERGABEWERT" .BR dup " und " dup2 geben den neuen descriptor zurück, oder \-1 falls ein Fehler auftrat (in diesem Falle wird auch .I errno entsprechend gesetzt). .SH FEHLER .TP .B EBADF .I oldfd ist kein offener file descriptor, oder .I newfd ist außerhalb des für Dateideskriptoren erlaubten Bereiches. .TP .B EMFILE Der Prozess hat schon die maximale Anzahl an file deskriptoren offen und versuchte einen weiteren zu öffnen. .SH WARNUNG Der Fehler, der von .B dup2 zurückgegeben wird, ist unterschiedlich zu demjenigen von .BR fcntl( ..., F_DUPFD ,... ) wenn .I newfd außerhalb des Bereiches ist. Weiterhin gibt .B dup2 auf einigen Systemen .B EINVAL wie .BR F_DUPFD zurück. .SH "KONFORM ZU" SVID, AT&T, POSIX, X/OPEN, BSD 4.3 .SH "SIEHE AUCH" .BR fcntl (2), .BR open (2), .BR close (2).