diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2014-05-03 17:49:05 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2014-05-03 17:51:19 -0300 |
commit | f54a37b4a960f8651ecb6ceb532ed9cf5c4a91f1 (patch) | |
tree | 124f6849999536fecf204d482634046373c8e117 /ProcessList.c | |
parent | c3e66b2d81d90b4ef0368e61ad3d67d0f062577d (diff) |
Update values for fields whose columns may appear later. Fixes #80.
Diffstat (limited to 'ProcessList.c')
-rw-r--r-- | ProcessList.c | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/ProcessList.c b/ProcessList.c index d3621155..46dc0a6b 100644 --- a/ProcessList.c +++ b/ProcessList.c @@ -242,8 +242,13 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList) { this->flags = 0; for (int i = 0; defaultHeaders[i]; i++) { this->fields[i] = defaultHeaders[i]; - this->fields[i] |= Process_fieldFlags[defaultHeaders[i]]; + this->flags |= Process_fieldFlags[defaultHeaders[i]]; } + + #ifdef HAVE_OPENVZ + this->flags |= PROCESS_FLAG_OPENVZ; + #endif + this->sortKey = PERCENT_CPU; this->direction = 1; this->hideThreads = false; @@ -580,9 +585,10 @@ static bool ProcessList_readStatmFile(Process* process, const char* dirname, con #ifdef HAVE_OPENVZ static void ProcessList_readOpenVZData(Process* process, const char* dirname, const char* name) { - if (access("/proc/vz", R_OK) != 0) { + if ( (!(this->flags & PROCESS_FLAG_OPENVZ)) || (access("/proc/vz", R_OK) != 0)) { process->vpid = process->pid; process->ctid = 0; + this->flags |= ~PROCESS_FLAG_OPENVZ; return; } char filename[MAX_NAME+1]; @@ -806,23 +812,13 @@ static bool ProcessList_processEntries(ProcessList* this, const char* dirname, P process->user = UsersTable_getRef(this->usersTable, process->st_uid); #ifdef HAVE_OPENVZ - if (this->flags & PROCESS_FLAG_OPENVZ) - ProcessList_readOpenVZData(process, dirname, name); - #endif - - #ifdef HAVE_CGROUP - if (this->flags & PROCESS_FLAG_CGROUP) - ProcessList_readCGroupFile(process, dirname, name); + ProcessList_readOpenVZData(process, dirname, name); #endif #ifdef HAVE_VSERVER if (this->flags & PROCESS_FLAG_VSERVER) ProcessList_readVServerData(process, dirname, name); #endif - - #ifdef HAVE_OOM - ProcessList_readOomData(process, dirname, name); - #endif if (! ProcessList_readCmdlineFile(process, dirname, name)) goto errorReadingProcess; @@ -835,6 +831,15 @@ static bool ProcessList_processEntries(ProcessList* this, const char* dirname, P } } + #ifdef HAVE_CGROUP + if (this->flags & PROCESS_FLAG_CGROUP) + ProcessList_readCGroupFile(process, dirname, name); + #endif + + #ifdef HAVE_OOM + ProcessList_readOomData(process, dirname, name); + #endif + if (process->state == 'Z') { free(process->comm); process->basenameOffset = -1; |