02-12-04 05:34 AM
On Thu, 12 Feb 2004 09:50:00 GMT, hoh@invalid.invalid (Goran Larsson) wrote:
>In article <barmar-05434C.02444312022004@comcast.ash.giganews.com>,
>Barry Margolin <barmar@alum.mit.edu> wrote:
>
>
>This is not true. A file that is held open by a process but had all
>its names removed (link count is zero) has no name. This should be
>known by all Unix admins.
>
>Situations with nameless files often happens when a process creates a
>quickly growing logfile and an admin removes the logfile in an attempt
>to free up disk space. The file will continue to exist, and grow,
>nameless until the process closes the file or dies.
From my Linux Newbies cluesheet #3, I offer this...
Have you ever found yourself in this position: you notice that
/var/log/messages (or some other syslog-owned file) has grown too big, and
you
rm /var/log/messages
touch /var/log/messages
to reclaim the space, but the used space doesn't reappear? This is because,
although you've deleted the filename part, there's a process that's got the
data part open still (syslogd), and the OS won't release the space for the
data until the process closes it. In order to complete your space
reclamation, you have to
kill -SIGHUP `cat /var/run/syslogd.pid`
to get syslogd to close and reopen the file
You can use this to your advantage in programs: have you ever wondered how
you could _hide_ a temporary file? Well, you
{
FILE *fp;
fp = fopen("some.hidden.file","w");
unlink("some.hidden.file"); /* deletes the filename part */
/* some.hidden.file no longer has a filename and is truely hidden */
fprintf(fp,"This data won't be found\n"); /* access the data part */
/*etc*/
fclose(fp); /* finally release the data part */
}
>--
>Göran Larsson http://www.mitt-eget.com/
--
Lew Pitcher
IT Consultant, Enterprise Technology Solutions
Toronto Dominion Bank Financial Group
(Opinions expressed are my own, not my employers')
[ Post a follow-up to this message ]
|