Browse Source

PrismFileLog: fix handling of close() call for stdout

If the underlying file handle corresponds to stdout, we ignore the
close() call. Correspondingly, we should not mark the log as closed,
as some of the functionality in PrismCL (e.g., for export to 'stdout'
in the explicit engine) relies on the possibility of closing the
corresponding log, leading to an exception. Bug was introduced during
recent efforts to make log closing more robust and catch
write-after-close use of logs.

Test case:
prism prism-examples/dice/dice.pm --exportmodel stdout.all -ex
master
Joachim Klein 7 years ago
parent
commit
9a2f7f47d5
  1. 7
      prism/src/prism/PrismFileLog.java

7
prism/src/prism/PrismFileLog.java

@ -146,7 +146,12 @@ public class PrismFileLog extends PrismLog
return;
}
if (!stdout) PrismNative.PN_CloseFile(fp);
if (stdout) {
// we never close stdout
return;
}
PrismNative.PN_CloseFile(fp);
// set fp to zero to indicate that the file handle is not valid anymore
fp = 0;
}

Loading…
Cancel
Save