]> git.sesse.net Git - nageru/blobdiff - shared/read_file.cpp
On errors, abort() instead of exit(1); exit() in a multithreaded program just gives...
[nageru] / shared / read_file.cpp
index 40846546b42ed4f11ca055ad9faafcbcaecc418e..77a23fdff0b07e181e506c9aa4b6d04357b4d297 100644 (file)
@@ -17,25 +17,25 @@ string read_file(const string &filename, const unsigned char *start, const size_
                }
 
                perror(filename.c_str());
-               exit(1);
+               abort();
        }
 
        int ret = fseek(fp, 0, SEEK_END);
        if (ret == -1) {
                perror("fseek(SEEK_END)");
-               exit(1);
+               abort();
        }
 
        int disk_size = ftell(fp);
        if (disk_size == -1) {
                perror("ftell");
-               exit(1);
+               abort();
        }
 
        ret = fseek(fp, 0, SEEK_SET);
        if (ret == -1) {
                perror("fseek(SEEK_SET)");
-               exit(1);
+               abort();
        }
 
        string str;
@@ -43,12 +43,12 @@ string read_file(const string &filename, const unsigned char *start, const size_
        ret = fread(&str[0], disk_size, 1, fp);
        if (ret == -1) {
                perror("fread");
-               exit(1);
+               abort();
        }
        if (ret == 0) {
                fprintf(stderr, "Short read when trying to read %d bytes from %s\n",
                        disk_size, filename.c_str());
-               exit(1);
+               abort();
        }
        fclose(fp);