filewrapper: _Exit instead of CHECK failing

Raw `SAPI_RAW_PCHECK` may dump core, depending on environment settings
(issue #89).
This is undesirable in the face of invalid command-line arguments.

Signed-off-by: Christian Blichmann <cblichmann@google.com>
This commit is contained in:
Christian Blichmann 2022-01-03 15:00:35 +01:00
parent e5a810eef4
commit 3745d58587
No known key found for this signature in database
GPG Key ID: A59C788ECA4FA381

View File

@ -97,7 +97,12 @@ class File {
}
~File() { fclose(stream_); }
void Check() { SAPI_RAW_PCHECK(!ferror(stream_), "I/O on %s", name_); }
void Check() {
if (ferror(stream_)) {
SAPI_RAW_PLOG(ERROR, "I/O on %s", name_);
_Exit(EXIT_FAILURE);
}
}
FILE* get() const { return stream_; }