[Top] [Prev] [Next]

dup

dup - duplicate an open file descriptor

Synopsis

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 type holds an integer-valued file descriptor, the form used by the operating system, in a structure that can be reference counted and garbage collected. There are occasions when a program must access the underlying integer file descriptor, such as arranging I/O re-direction for the standard input and output for a new process.

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 Modules and open



[Top] [Prev] [Next]

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