include "sys.m"; sys := load Sys Sys->PATH; dup: fn(oldfd, newfd: int): int; fildes: fn(fd: int): ref FD;
The dup call takes a valid integer file descriptor, oldfd, referring to an open file, and returns a new integer file descriptor referring to the same file. If newfd is in the range of legal file descriptors, dup will use that for the new file descriptor (closing any old file associated with newfd); if newfd is -1 the system chooses the lowest available file descriptor. If a suitable file descriptor cannot be found, dup returns -1.
Fildes duplicates the integer file descriptor fd, as if by sys->dup(fd,-1), and returns a reference to the new descriptor as an FD value, making it usable by other functions in Sys, such as sys-print(2) and sys-read(2). (Note that as described above, the newly-allocated file descriptor will be closed automatically when the FD value is reclaimed.) Fildes returns nil if it cannot duplicate fd.
SYS-DUP(2 ) | Rev: Tue Mar 31 02:42:39 GMT 2015 |