relinking a file still held open by a unix filehandle

relinking a file still held open by a unix filehandle

Post by Alex Bel » Fri, 15 Jun 2001 21:16:20



All,

I recently had a situation where a Netscape Enterprise Server was not
producing log files, after digging around I found it still had a file handle
open to a log file that no longer existed, obviously someone had removed the
file but the server was still logging to it. I sorted the problem by
stopping & restarting the netscape processes.
I just wondered if in such a situation it was possible to recreate a link to
that file and thereby the file itself using link or some such call?

thanks
Alex

 
 
 

relinking a file still held open by a unix filehandle

Post by Juergen Kei » Sat, 16 Jun 2001 02:26:34



> I recently had a situation where a Netscape Enterprise Server was not
> producing log files, after digging around I found it still had a file handle
> open to a log file that no longer existed, obviously someone had removed the
> file but the server was still logging to it. I sorted the problem by
> stopping & restarting the netscape processes.
> I just wondered if in such a situation it was possible to recreate a link to
> that file and thereby the file itself using link or some such call?

Restoring the filesystem link is not possible.  But you can still
access the file's data using the appropritate /proc/$pid/fd/$fd file
(Solaris 2.6 or later).

$pid is the PID of the process that keeps a reference to the deleted
file, $fd is the file descriptor number of the log file in that
process.