[project @ 1997-03-14 05:17:06 by sof]
[ghc-hetmet.git] / ghc / lib / cbits / closeFile.lc
index f3efb34..9f4c80e 100644 (file)
 
 StgInt
 closeFile(fp)
-StgAddr fp;
+StgForeignObj fp;
 {
     int rc;
 
-    unlockFile(fileno((FILE *) fp));
+    if (unlockFile(fileno((FILE *) fp))) {
+       /* If it has been unlocked, don't bother fclose()ing */
+       return 0;
+    }
 
     while ((rc = fclose((FILE *) fp)) != 0) {
        if (errno != EINTR) {