[Top] [Prev] [Next]

dup - duplicate an open file descriptor

include "sys.m";
sys:= load Sys Sys->PATH;
dup:    fn(oldfd, newfd: int): int;
fildes: fn(fd: int):           ref FD;

Description

The Limbo programming language and its libraries manage I/O via references to instances of an abstract data type, FD, called a file descriptor. This command duplicates an open file descriptor.

dup (oldfd, newfd)

The dup function 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 (fd)

The fildes function uses the integer file descriptor fd to create a new Limbo file descriptor, suitable for other Sys module functions. It returns nil if it cannot convert fd.

See Also

Limbo System Module and open, create - open/create a file for reading or writing



[Top] [Prev] [Next]

infernosupport@lucent.com
Copyright © 1996,Lucent Technologies, Inc. All rights reserved.