[Next] [Up] [Previous]
Next: Dup2 Up: Functions and procedures Previous: Fcntl

Dup

   

Declaration:

Procedure Dup (Var OldFile, NewFile : Text) ;

Description:

Makes NewFile an exact copy of OldFile, after having flushed the buffer of OldFile. Due to the buffering mechanism of Pascal, this has not the same functionality as the dup(2) call in C. The internal Pascal buffers are not the same after this call, but when the buffers are flushed (e.g. after output), the output is sent to the same file. Doing an lseek will, however, work as in C, i.e. doing a lseek will change the fileposition in both files.

Errors:

Linuxerror is used to report errors.

sys_ebadf
OldFile hasn't been assigned.
sys_emfile
Maximum number of open files for the process is reached.

See also:

Dup2, Dup(2)



Michael Van Canneyt
Thu Dec 12 15:40:07 MET 1996