[project @ 1997-03-14 05:17:06 by sof]
[ghc-hetmet.git] / ghc / lib / cbits / closeFile.lc
1 %
2 % (c) The GRASP/AQUA Project, Glasgow University, 1994
3 %
4 \subsection[closeFile.lc]{hClose Runtime Support}
5
6 \begin{code}
7
8 #include "rtsdefs.h"
9 #include "stgio.h"
10
11 StgInt
12 closeFile(fp)
13 StgForeignObj fp;
14 {
15     int rc;
16
17     if (unlockFile(fileno((FILE *) fp))) {
18        /* If it has been unlocked, don't bother fclose()ing */
19        return 0;
20     }
21
22     while ((rc = fclose((FILE *) fp)) != 0) {
23         if (errno != EINTR) {
24             cvtErrno();
25             stdErrno();
26             return rc;
27         }
28     }
29     return 0;
30 }
31
32 \end{code}
33
34
35