diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2012-10-19 18:59:48 +0000 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2012-10-19 18:59:48 +0000 |
commit | 1b21827f1f875692e14ee5ac9b22f3fd69fd8593 (patch) | |
tree | 7746d8fe6864bfa47292caa65aa8fb944d1eb752 /ProcessList.c | |
parent | 47e881f460cfb441be64a1ff17295357fb02d0ad (diff) |
Fail gracefully when /proc is not mounted
(thanks to Philipp Hagemeister)
Diffstat (limited to 'ProcessList.c')
-rw-r--r-- | ProcessList.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/ProcessList.c b/ProcessList.c index 268793f2..30cc8012 100644 --- a/ProcessList.c +++ b/ProcessList.c @@ -193,7 +193,9 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList) { this->processes2 = Vector_new(PROCESS_CLASS, true, DEFAULT_SIZE, Process_compare); FILE* file = fopen(PROCSTATFILE, "r"); - assert(file != NULL); + if (file == NULL) { + CRT_fatalError("Cannot open " PROCSTATFILE); + } char buffer[256]; int cpus = -1; do { @@ -758,7 +760,9 @@ void ProcessList_scan(ProcessList* this) { unsigned long long int swapFree = 0; FILE* file = fopen(PROCMEMINFOFILE, "r"); - assert(file != NULL); + if (file == NULL) { + CRT_fatalError("Cannot open " PROCMEMINFOFILE); + } int cpus = this->cpuCount; { char buffer[128]; @@ -796,7 +800,9 @@ void ProcessList_scan(ProcessList* this) { fclose(file); file = fopen(PROCSTATFILE, "r"); - assert(file != NULL); + if (file == NULL) { + CRT_fatalError("Cannot open " PROCSTATFILE); + } for (int i = 0; i <= cpus; i++) { char buffer[256]; int cpuid; |