[project @ 1998-04-10 10:54:14 by simonm]
[ghc-hetmet.git] / ghc / lib / std / cbits / closeFile.c
1 /* 
2  * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
3  *
4  * $Id: closeFile.c,v 1.1 1998/04/10 10:54:14 simonm Exp $
5  *
6  * hClose Runtime Support
7  */
8
9 #include "Rts.h"
10 #include "stgio.h"
11
12 StgInt
13 closeFile(StgAddr 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
33