Xref: utzoo comp.lang.c:28522 comp.unix.questions:22034 comp.unix.wizards:21853 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!uakari.primate.wisc.edu!uflorida!haven!h.cs.wvu.wvnet.edu!cerc.wvu.wvnet.edu!cathedral!kannan From: kannan@cathedral.cerc.wvu.wvnet.edu (R. Kannan) Newsgroups: comp.lang.c,comp.unix.questions,comp.unix.wizards Subject: fdopen , open and memory release within scope ... Keywords: fdopen , open, FILE *, free , cfree, fclose and close .... Message-ID: <520@cerc.wvu.wvnet.edu.edu> Date: 7 May 90 21:41:25 GMT Sender: news@cerc.wvu.wvnet.edu Followup-To: comp.lang.c Lines: 56 ---====================== PSEUDO CODE ---====================== fn2(x) int x ; { FILE *fx , *fopen ; fx = fdopen (x,.... ); /* memory gets allocated */ /* want to free the memory without closing the file descriptor so that file descriptor can be used in the caller's scope and close within that scope */ fclose (fx ) ; /* WILL CLOSE THE FILE associated withe the input parameter as well isnt it? /* rest of fn2 */ } fn1() { int x ; x= open ( filename, mode etc ); fn2(x) ; /* want to do other things as well as close the x */ } ---====== PROBLEM:: I want to do pass a file descriptor to a function wherein the function converts the file descriptor to a FILE pointer using fdopen. Now on exiting from the function I want to free all memories allocated (because of the FILE poitner) and leave the file descriptor in tact. Could you please e-mail to me if you have any sugestions. Please do E-MAIL. Prefer e-mail than posting to the whole net. Will summarize if there are requests .... --kannan