*BSD News Article 76743


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!news.cs.su.oz.au!metro!metro!asstdc.scgt.oz.au!nsw.news.telstra.net!act.news.telstra.net!psgrain!iafrica.com!uct.ac.za!quagga.ru.ac.za!howland.erols.net!newsfeed.internetmci.com!news.texas.net!nntp04.primenet.com!nntp.primenet.com!newspump.sol.net!uwm.edu!math.ohio-state.edu!jussieu.fr!rain.fr!speedy.grolier.fr!news-lond.gsl.net!news.gsl.net!dispatch.news.demon.net!demon!awfulhak.demon.co.uk!awfulhak.demon.co.uk!awfulhak.demon.co.
uk!not-for-mail
From: brian@awfulhak.demon.co.uk (Brian Somers)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: How to determine fd's owner?
Date: 22 Aug 1996 14:56:23 +0100
Organization: Coverform Ltd.
Lines: 33
Message-ID: <4vhou7$bm@anorak.coverform.lan>
References: <4v1fj3$8pm@itchy.serv.net>
NNTP-Posting-Host: localhost.coverform.lan
X-NNTP-Posting-Host: awfulhak.demon.co.uk
X-Newsreader: TIN [version 1.2 PL2]

Sean T. Lamont (zeno@serv.net) wrote:
: I have a bit of a connundrum.

: For system reasons, on an NFS-mounted partition, 
: I'm doing the equivalent of the following:

: open "file", read contents, close file1.
: open "file1.n" for write, write contents of file1.n, close file1.n.
: rename "file1.n" to "file1".

People have already mentioned fstat and lsof.

However, this should not be a problem.  I'd suggest examining your
code for an out-by-one error.... something like:

    char Buffer[512];
    int fd1, fd2;

    if( fd1 = open( "fromfile", O_RDONLY ), fd1 == -1 )
	....
    read( fd1, Buffer, 513 );
    close( fd1 );

Try getting your program to output each file descriptor returned by
open() - if they keep increasing, you're not successfully close()ing ! 
The only thing that can be gobbling the disk space is a failed close.

Of course, if killing your program doesn't give back the disk space,
this won't be helpful :(

--
Brian <brian@awfulhak.demon.co.uk>
Don't _EVER_ lose your sense of humour....