Asynchronous File I/O on Linux

Bill Bogstad bogstad-e+AXbWqSrlAAvxtiuMwx3w at public.gmane.org
Sat May 15 23:11:32 EDT 2010


On Sat, May 15, 2010 at 5:56 PM, Mark Woodward <markw-FJ05HQ0HCKaWd6l5hS35sQ at public.gmane.org> wrote:
> Bill Bogstad wrote:

>
> OK, so, the methodology is quite similar, fine. Now the question remains, is
> it possible to quickly "clone" an existing file handle so that it will be a
> new and distinct file handle with the same permissions and modes with its
> own distict view of current location, i.e. seek on one does not affect seek
> on the other?

The closest that I can think of involves /proc/self/fd.   It doesn't
do same permissions/modes, but does
give you different seek pointers.  I suspect it only works with
seekable (i.e. disk file) file descriptors...

/* crappy (uncompiled) code follows */
sprintf(bigbuf, "/proc/self/fd/%d", oldfd);
newfd = open(bigbuf, flags);

Bill Bogstad





More information about the Discuss mailing list