summaryrefslogtreecommitdiff
path: root/ghc/runtime/io/closeFile.lc
blob: f3efb3488de60abe78d1a089985099ddfc8dc49c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
%
% (c) The GRASP/AQUA Project, Glasgow University, 1994
%
\subsection[closeFile.lc]{hClose Runtime Support}

\begin{code}

#include "rtsdefs.h"
#include "stgio.h"

StgInt
closeFile(fp)
StgAddr fp;
{
    int rc;

    unlockFile(fileno((FILE *) fp));

    while ((rc = fclose((FILE *) fp)) != 0) {
	if (errno != EINTR) {
	    cvtErrno();
	    stdErrno();
	    return rc;
	}
    }
    return 0;
}

\end{code}