|
294 | 294 | can \texttt{rm} all hard links to a specific file but if a process has the file |
295 | 295 | still open, the file data remains on the disk until the process closes the file |
296 | 296 | or terminates. |
297 | | -\item If a process needs a temporary file, it can create it, \texttt{unlink} it |
298 | | -right away, and work with it using the existing file descriptor. When the file |
299 | | -descriptor is closed (and all of its possible duplicates), the file data is |
300 | | -released. |
| 297 | +\item If a process needs a temporary file, it can create it, \texttt{unlink} |
| 298 | +(see page \pageref{UNLINK}) it right away, and work with it using the existing |
| 299 | +file descriptor. When the file descriptor is closed (and all of its possible |
| 300 | +duplicates), the file data is released. |
301 | 301 | \item Even \texttt{close} may fail. For example, some filesystems may write the |
302 | 302 | data on file closure (NFS), and if that write fails, \texttt{close} fails. |
303 | 303 | \item If you forget to close file descriptors when you no longer need them, |
|
912 | 912 | \emph{path2} to file \emph{path1}. Hard links cannot span filesystems (use |
913 | 913 | \funnm{symlink} for that). |
914 | 914 | \end{itemize} |
915 | | -\texttt{ int \funnm{unlink}(const char *\emph{path});} |
| 915 | +\label{UNLINK} \texttt{ int \funnm{unlink}(const char *\emph{path});} |
916 | 916 | \begin{itemize} |
917 | 917 | \item deletes a name (i.e. a directory entry) and after deleting the last link to |
918 | 918 | the file and after closing the file by all processes, deletes the file data. |
|
0 commit comments