Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!watmath!clyde!rutgers!seismo!mcvax!ukc!its63b!simon
From: simon@its63b.UUCP
Newsgroups: comp.unix.wizards
Subject: Re: cancelling fdopen(3)
Message-ID: <169@its63b.ed.ac.uk>
Date: Wed, 10-Dec-86 11:38:36 EST
Article-I.D.: its63b.169
Posted: Wed Dec 10 11:38:36 1986
Date-Received: Sun, 14-Dec-86 11:31:38 EST
References: <88@dcl-csvax.comp.lancs.ac.uk>
Reply-To: simon@its63b.ed.ac.uk (ECSC68 S Brown CS)
Distribution: world
Organization: I.T. School, Univ. of Edinburgh, U.K.
Lines: 22
Keywords: fdopen, fclose, dup, stdio

In article <88@dcl-csvax.comp.lancs.ac.uk> stephen@comp.lancs.ac.uk (Stephen J. Muir) writes:
>I need to open a file, then allocate a FILE * structure to it:
>
>FILE *f_fd = fdopen (fd, "w");
>
>Now, what is the best way to release the FILE * structure to the free pool
>without closing the file attached to the original "fd"?
>

Well, the easiest way would be to put
	FILE *f_fd = fdopen (dup(fd), "w");
and then you can release the FILE * structure with fclose(f_fd),
which will close only the dup of fd, not fd itself.

--
Simon Brown
Department of Computer Science, University of Edinburgh, Scotland.
...!{ihnp4,seismo,decvax}!mcvax!ukc!cstvax(!its63b)!simon

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Life's a load of tripe - that's my gripe". [Anon.]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~