Pascal / BaseUnix / FpDup2
FpAccess, FpAlarm, FpChdir, FpChmod, FpChown, FpClose, FpClosedir, FpDup, » FpDup2, FpExecv, FpExecve, FpExit, FpFcntl, pfdfillset, fpFD_CLR, fpFD_ISSET, fpFD_SET, fpFD_ZERO, FpFork, FPFStat, FpFtruncate, FpGetcwd, FpGetegid, FpGetEnv, fpgeterrno, FpGeteuid, FpGetgid, FpGetgroups, FpGetpgrp, FpGetpid, FpGetppid, fpGetPriority, FpGetuid, FpIOCtl, FpKill, FpLink, FpLseek, fpLstat, FpMkdir, FpMkfifo, Fpmmap, Fpmunmap, FpNanoSleep, fpNice, FpOpen, FpOpendir, FpPause, FpPipe, FpRead, FpReaddir, fpReadLink, FpRename, FpRmdir, fpSelect, fpseterrno, FpSetgid, fpSetPriority, FpSetsid, fpsettimeofday, FpSetuid,
Funcion: FpDup2()
Sintaxis:
function FpDup2(
 
  fildes: cInt;
 
  fildes2: cInt
 
):cInt;
 
function FpDup2(
 
  var oldfi

Descripcion: Duplica un apuntador de arhivo a otro.

La funcion regresa zero si se ejecuto con exito, y un valor diferente de cero si ocurrio un error.

ERRORES:
En aso de un error, los siguientes codigos pueden ser reportados.

sys_ebadf --> OldFile no ha sido asignado

sys_emfile --> el numero maximo de archivos abiertos ha sido alcanzado.
Ejemplo:
program Example31;
 
{ Program to demonstrate the Dup function. }
 
uses BaseUnix;
 
var f : text;
    i : longint;
 
begin
  Assign (f,'text.txt');
  Rewrite (F);
  For i:=1 to 10 do writeln (F,'Line : ',i);
  if fpdup2 (output,f)<>0 then
    Writeln ('Dup2 Failed !');
  writeln ('This is written to stdout.');
  writeln (f,'This is written to the dup file, and flushed');
  flush(f);
  writeln;
  { Remove file. Comment this if you want to check flushing.}
  fpUnlink ('text.txt');
end.

Librerias Pascal

Libreria crt - CRT - Pantalla y teclado del PASCAL de Turbo que maneja la unidad
Libreria dos - DOS - Interface Turbo Pascal MS-DOS
Libreria Graph - Unidad para manipular los graficos de la pantalla compatible con TP
Libreria Objects - Objetos basicos compatible con TP
Libreria math - Rutinas adicionales matematicas
Libreria Printer - Provee de acceso a la impresora
Libreria strings - Rutinas para el manejo de cadenas
Libreria BaseUnix - Funcionalidad Basica de Linux
Libreria System - Manejo de Archivos - Funciones para la manipulacion de archivos en Pascal