mirror of https://github.com/xzeldon/htop.git
Spacing after keywords (if)
This commit is contained in:
parent
0a51eae11f
commit
374edb9ed5
4
CRT.c
4
CRT.c
|
@ -770,7 +770,7 @@ void CRT_handleSIGSEGV(int signal) {
|
||||||
);
|
);
|
||||||
|
|
||||||
const char* signal_str = strsignal(signal);
|
const char* signal_str = strsignal(signal);
|
||||||
if(!signal_str) {
|
if (!signal_str) {
|
||||||
signal_str = "unknown reason";
|
signal_str = "unknown reason";
|
||||||
}
|
}
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
|
@ -821,7 +821,7 @@ void CRT_handleSIGSEGV(int signal) {
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Call old sigsegv handler; may be default exit or third party one (e.g. ASAN) */
|
/* Call old sigsegv handler; may be default exit or third party one (e.g. ASAN) */
|
||||||
if(sigaction (signal, &old_sig_handler[signal], NULL) < 0) {
|
if (sigaction (signal, &old_sig_handler[signal], NULL) < 0) {
|
||||||
/* This avoids an infinite loop in case the handler could not be reset. */
|
/* This avoids an infinite loop in case the handler could not be reset. */
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"!!! Chained handler could not be restored. Forcing exit.\n"
|
"!!! Chained handler could not be restored. Forcing exit.\n"
|
||||||
|
|
|
@ -325,7 +325,7 @@ void Process_writeField(const Process* this, RichString* str, ProcessField field
|
||||||
case PID: xSnprintf(buffer, n, Process_pidFormat, this->pid); break;
|
case PID: xSnprintf(buffer, n, Process_pidFormat, this->pid); break;
|
||||||
case PPID: xSnprintf(buffer, n, Process_pidFormat, this->ppid); break;
|
case PPID: xSnprintf(buffer, n, Process_pidFormat, this->ppid); break;
|
||||||
case PRIORITY: {
|
case PRIORITY: {
|
||||||
if(this->priority <= -100)
|
if (this->priority <= -100)
|
||||||
xSnprintf(buffer, n, " RT ");
|
xSnprintf(buffer, n, " RT ");
|
||||||
else
|
else
|
||||||
xSnprintf(buffer, n, "%3ld ", this->priority);
|
xSnprintf(buffer, n, "%3ld ", this->priority);
|
||||||
|
|
|
@ -81,10 +81,10 @@ bool TraceScreen_forkTracer(TraceScreen* this) {
|
||||||
if (pipe(fdpair) == -1)
|
if (pipe(fdpair) == -1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(fcntl(fdpair[0], F_SETFL, O_NONBLOCK) < 0)
|
if (fcntl(fdpair[0], F_SETFL, O_NONBLOCK) < 0)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
if(fcntl(fdpair[1], F_SETFL, O_NONBLOCK) < 0)
|
if (fcntl(fdpair[1], F_SETFL, O_NONBLOCK) < 0)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
pid_t child = fork();
|
pid_t child = fork();
|
||||||
|
|
4
Vector.c
4
Vector.c
|
@ -201,7 +201,7 @@ void Vector_insert(Vector* this, int idx, void* data_) {
|
||||||
|
|
||||||
Vector_checkArraySize(this);
|
Vector_checkArraySize(this);
|
||||||
//assert(this->array[this->items] == NULL);
|
//assert(this->array[this->items] == NULL);
|
||||||
if(idx < this->items) {
|
if (idx < this->items) {
|
||||||
memmove(&this->array[idx + 1], &this->array[idx], (this->items - idx) * sizeof(this->array[0]));
|
memmove(&this->array[idx + 1], &this->array[idx], (this->items - idx) * sizeof(this->array[0]));
|
||||||
}
|
}
|
||||||
this->array[idx] = data;
|
this->array[idx] = data;
|
||||||
|
@ -215,7 +215,7 @@ Object* Vector_take(Vector* this, int idx) {
|
||||||
Object* removed = this->array[idx];
|
Object* removed = this->array[idx];
|
||||||
assert(removed);
|
assert(removed);
|
||||||
this->items--;
|
this->items--;
|
||||||
if(idx < this->items) {
|
if (idx < this->items) {
|
||||||
memmove(&this->array[idx], &this->array[idx + 1], (this->items - idx) * sizeof(this->array[0]));
|
memmove(&this->array[idx], &this->array[idx + 1], (this->items - idx) * sizeof(this->array[0]));
|
||||||
}
|
}
|
||||||
//this->array[this->items] = NULL;
|
//this->array[this->items] = NULL;
|
||||||
|
|
|
@ -13,7 +13,7 @@ void Battery_getData(double* level, ACPresence* isOnAC) {
|
||||||
*level = NAN;
|
*level = NAN;
|
||||||
*isOnAC = AC_ERROR;
|
*isOnAC = AC_ERROR;
|
||||||
|
|
||||||
if(NULL == power_sources) {
|
if (NULL == power_sources) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ void Battery_getData(double* level, ACPresence* isOnAC) {
|
||||||
CFDictionaryRef battery = NULL;
|
CFDictionaryRef battery = NULL;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if(NULL == list) {
|
if (NULL == list) {
|
||||||
CFRelease(power_sources);
|
CFRelease(power_sources);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -35,18 +35,18 @@ void Battery_getData(double* level, ACPresence* isOnAC) {
|
||||||
CFArrayGetValueAtIndex(list, i)); /* GET rule */
|
CFArrayGetValueAtIndex(list, i)); /* GET rule */
|
||||||
CFStringRef type;
|
CFStringRef type;
|
||||||
|
|
||||||
if(NULL != candidate) {
|
if (NULL != candidate) {
|
||||||
type = (CFStringRef) CFDictionaryGetValue(candidate,
|
type = (CFStringRef) CFDictionaryGetValue(candidate,
|
||||||
CFSTR(kIOPSTransportTypeKey)); /* GET rule */
|
CFSTR(kIOPSTransportTypeKey)); /* GET rule */
|
||||||
|
|
||||||
if(kCFCompareEqualTo == CFStringCompare(type, CFSTR(kIOPSInternalType), 0)) {
|
if (kCFCompareEqualTo == CFStringCompare(type, CFSTR(kIOPSInternalType), 0)) {
|
||||||
CFRetain(candidate);
|
CFRetain(candidate);
|
||||||
battery = candidate;
|
battery = candidate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(NULL != battery) {
|
if (NULL != battery) {
|
||||||
/* Determine the AC state */
|
/* Determine the AC state */
|
||||||
CFStringRef power_state = CFDictionaryGetValue(battery, CFSTR(kIOPSPowerSourceStateKey));
|
CFStringRef power_state = CFDictionaryGetValue(battery, CFSTR(kIOPSPowerSourceStateKey));
|
||||||
|
|
||||||
|
|
|
@ -212,7 +212,7 @@ void DarwinProcess_setFromKInfoProc(Process *proc, struct kinfo_proc *ps, bool e
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* First, the "immutable" parts */
|
/* First, the "immutable" parts */
|
||||||
if(!exists) {
|
if (!exists) {
|
||||||
/* Set the PID/PGID/etc. */
|
/* Set the PID/PGID/etc. */
|
||||||
proc->pid = ep->p_pid;
|
proc->pid = ep->p_pid;
|
||||||
proc->ppid = ps->kp_eproc.e_ppid;
|
proc->ppid = ps->kp_eproc.e_ppid;
|
||||||
|
@ -244,8 +244,8 @@ void DarwinProcess_setFromKInfoProc(Process *proc, struct kinfo_proc *ps, bool e
|
||||||
void DarwinProcess_setFromLibprocPidinfo(DarwinProcess *proc, DarwinProcessList *dpl) {
|
void DarwinProcess_setFromLibprocPidinfo(DarwinProcess *proc, DarwinProcessList *dpl) {
|
||||||
struct proc_taskinfo pti;
|
struct proc_taskinfo pti;
|
||||||
|
|
||||||
if(sizeof(pti) == proc_pidinfo(proc->super.pid, PROC_PIDTASKINFO, 0, &pti, sizeof(pti))) {
|
if (sizeof(pti) == proc_pidinfo(proc->super.pid, PROC_PIDTASKINFO, 0, &pti, sizeof(pti))) {
|
||||||
if(0 != proc->utime || 0 != proc->stime) {
|
if (0 != proc->utime || 0 != proc->stime) {
|
||||||
uint64_t diff = (pti.pti_total_system - proc->stime)
|
uint64_t diff = (pti.pti_total_system - proc->stime)
|
||||||
+ (pti.pti_total_user - proc->utime);
|
+ (pti.pti_total_user - proc->utime);
|
||||||
|
|
||||||
|
|
|
@ -57,14 +57,14 @@ int CompareKernelVersion(short int major, short int minor, short int component)
|
||||||
void ProcessList_getHostInfo(host_basic_info_data_t *p) {
|
void ProcessList_getHostInfo(host_basic_info_data_t *p) {
|
||||||
mach_msg_type_number_t info_size = HOST_BASIC_INFO_COUNT;
|
mach_msg_type_number_t info_size = HOST_BASIC_INFO_COUNT;
|
||||||
|
|
||||||
if(0 != host_info(mach_host_self(), HOST_BASIC_INFO, (host_info_t)p, &info_size)) {
|
if (0 != host_info(mach_host_self(), HOST_BASIC_INFO, (host_info_t)p, &info_size)) {
|
||||||
CRT_fatalError("Unable to retrieve host info\n");
|
CRT_fatalError("Unable to retrieve host info\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcessList_freeCPULoadInfo(processor_cpu_load_info_t *p) {
|
void ProcessList_freeCPULoadInfo(processor_cpu_load_info_t *p) {
|
||||||
if(NULL != p && NULL != *p) {
|
if (NULL != p && NULL != *p) {
|
||||||
if(0 != munmap(*p, vm_page_size)) {
|
if (0 != munmap(*p, vm_page_size)) {
|
||||||
CRT_fatalError("Unable to free old CPU load information\n");
|
CRT_fatalError("Unable to free old CPU load information\n");
|
||||||
}
|
}
|
||||||
*p = NULL;
|
*p = NULL;
|
||||||
|
@ -76,7 +76,7 @@ unsigned ProcessList_allocateCPULoadInfo(processor_cpu_load_info_t *p) {
|
||||||
unsigned cpu_count;
|
unsigned cpu_count;
|
||||||
|
|
||||||
// TODO Improving the accuracy of the load counts woule help a lot.
|
// TODO Improving the accuracy of the load counts woule help a lot.
|
||||||
if(0 != host_processor_info(mach_host_self(), PROCESSOR_CPU_LOAD_INFO, &cpu_count, (processor_info_array_t *)p, &info_size)) {
|
if (0 != host_processor_info(mach_host_self(), PROCESSOR_CPU_LOAD_INFO, &cpu_count, (processor_info_array_t *)p, &info_size)) {
|
||||||
CRT_fatalError("Unable to retrieve CPU info\n");
|
CRT_fatalError("Unable to retrieve CPU info\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,7 +200,7 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
|
||||||
|
|
||||||
super->totalTasks += 1;
|
super->totalTasks += 1;
|
||||||
|
|
||||||
if(!preExisting) {
|
if (!preExisting) {
|
||||||
proc->super.user = UsersTable_getRef(super->usersTable, proc->super.st_uid);
|
proc->super.user = UsersTable_getRef(super->usersTable, proc->super.st_uid);
|
||||||
|
|
||||||
ProcessList_add(super, &proc->super);
|
ProcessList_add(super, &proc->super);
|
||||||
|
|
|
@ -149,7 +149,7 @@ int Platform_getUptime() {
|
||||||
void Platform_getLoadAverage(double* one, double* five, double* fifteen) {
|
void Platform_getLoadAverage(double* one, double* five, double* fifteen) {
|
||||||
double results[3];
|
double results[3];
|
||||||
|
|
||||||
if(3 == getloadavg(results, 3)) {
|
if (3 == getloadavg(results, 3)) {
|
||||||
*one = results[0];
|
*one = results[0];
|
||||||
*five = results[1];
|
*five = results[1];
|
||||||
*fifteen = results[2];
|
*fifteen = results[2];
|
||||||
|
|
|
@ -417,7 +417,7 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
|
||||||
dfp->jname = DragonFlyBSDProcessList_readJailName(dfpl, kproc->kp_jailid);
|
dfp->jname = DragonFlyBSDProcessList_readJailName(dfpl, kproc->kp_jailid);
|
||||||
} else {
|
} else {
|
||||||
proc->processor = kproc->kp_lwp.kl_cpuid;
|
proc->processor = kproc->kp_lwp.kl_cpuid;
|
||||||
if(dfp->jid != kproc->kp_jailid) { // process can enter jail anytime
|
if (dfp->jid != kproc->kp_jailid) { // process can enter jail anytime
|
||||||
dfp->jid = kproc->kp_jailid;
|
dfp->jid = kproc->kp_jailid;
|
||||||
free(dfp->jname);
|
free(dfp->jname);
|
||||||
dfp->jname = DragonFlyBSDProcessList_readJailName(dfpl, kproc->kp_jailid);
|
dfp->jname = DragonFlyBSDProcessList_readJailName(dfpl, kproc->kp_jailid);
|
||||||
|
@ -425,7 +425,7 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
|
||||||
if (proc->ppid != kproc->kp_ppid) { // if there are reapers in the system, process can get reparented anytime
|
if (proc->ppid != kproc->kp_ppid) { // if there are reapers in the system, process can get reparented anytime
|
||||||
proc->ppid = kproc->kp_ppid;
|
proc->ppid = kproc->kp_ppid;
|
||||||
}
|
}
|
||||||
if(proc->st_uid != kproc->kp_uid) { // some processes change users (eg. to lower privs)
|
if (proc->st_uid != kproc->kp_uid) { // some processes change users (eg. to lower privs)
|
||||||
proc->st_uid = kproc->kp_uid;
|
proc->st_uid = kproc->kp_uid;
|
||||||
proc->user = UsersTable_getRef(super->usersTable, proc->st_uid);
|
proc->user = UsersTable_getRef(super->usersTable, proc->st_uid);
|
||||||
}
|
}
|
||||||
|
|
|
@ -502,7 +502,7 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
|
||||||
proc->comm = FreeBSDProcessList_readProcessName(fpl->kd, kproc, &proc->basenameOffset);
|
proc->comm = FreeBSDProcessList_readProcessName(fpl->kd, kproc, &proc->basenameOffset);
|
||||||
fp->jname = FreeBSDProcessList_readJailName(kproc);
|
fp->jname = FreeBSDProcessList_readJailName(kproc);
|
||||||
} else {
|
} else {
|
||||||
if(fp->jid != kproc->ki_jid) {
|
if (fp->jid != kproc->ki_jid) {
|
||||||
// process can enter jail anytime
|
// process can enter jail anytime
|
||||||
fp->jid = kproc->ki_jid;
|
fp->jid = kproc->ki_jid;
|
||||||
free(fp->jname);
|
free(fp->jname);
|
||||||
|
@ -512,7 +512,7 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
|
||||||
// if there are reapers in the system, process can get reparented anytime
|
// if there are reapers in the system, process can get reparented anytime
|
||||||
proc->ppid = kproc->ki_ppid;
|
proc->ppid = kproc->ki_ppid;
|
||||||
}
|
}
|
||||||
if(proc->st_uid != kproc->ki_uid) {
|
if (proc->st_uid != kproc->ki_uid) {
|
||||||
// some processes change users (eg. to lower privs)
|
// some processes change users (eg. to lower privs)
|
||||||
proc->st_uid = kproc->ki_uid;
|
proc->st_uid = kproc->ki_uid;
|
||||||
proc->user = UsersTable_getRef(super->usersTable, proc->st_uid);
|
proc->user = UsersTable_getRef(super->usersTable, proc->st_uid);
|
||||||
|
|
6
htop.c
6
htop.c
|
@ -186,7 +186,7 @@ static CommandLineSettings parseArguments(int argc, char** argv) {
|
||||||
char* saveptr;
|
char* saveptr;
|
||||||
char* pid = strtok_r(argCopy, ",", &saveptr);
|
char* pid = strtok_r(argCopy, ",", &saveptr);
|
||||||
|
|
||||||
if(!flags.pidMatchList) {
|
if (!flags.pidMatchList) {
|
||||||
flags.pidMatchList = Hashtable_new(8, false);
|
flags.pidMatchList = Hashtable_new(8, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@ static void setCommFilter(State* state, char** commFilter) {
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
|
|
||||||
char *lc_ctype = getenv("LC_CTYPE");
|
char *lc_ctype = getenv("LC_CTYPE");
|
||||||
if(lc_ctype != NULL)
|
if (lc_ctype != NULL)
|
||||||
setlocale(LC_CTYPE, lc_ctype);
|
setlocale(LC_CTYPE, lc_ctype);
|
||||||
else if ((lc_ctype = getenv("LC_ALL")))
|
else if ((lc_ctype = getenv("LC_ALL")))
|
||||||
setlocale(LC_CTYPE, lc_ctype);
|
setlocale(LC_CTYPE, lc_ctype);
|
||||||
|
@ -334,7 +334,7 @@ int main(int argc, char** argv) {
|
||||||
UsersTable_delete(ut);
|
UsersTable_delete(ut);
|
||||||
Settings_delete(settings);
|
Settings_delete(settings);
|
||||||
|
|
||||||
if(flags.pidMatchList) {
|
if (flags.pidMatchList) {
|
||||||
Hashtable_delete(flags.pidMatchList);
|
Hashtable_delete(flags.pidMatchList);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -244,11 +244,11 @@ void LinuxProcess_writeField(const Process* this, RichString* str, ProcessField
|
||||||
case IO_WRITE_RATE: Process_outputRate(str, buffer, n, lp->io_rate_write_bps, coloring); return;
|
case IO_WRITE_RATE: Process_outputRate(str, buffer, n, lp->io_rate_write_bps, coloring); return;
|
||||||
case IO_RATE: {
|
case IO_RATE: {
|
||||||
double totalRate = NAN;
|
double totalRate = NAN;
|
||||||
if(!isnan(lp->io_rate_read_bps) && !isnan(lp->io_rate_write_bps))
|
if (!isnan(lp->io_rate_read_bps) && !isnan(lp->io_rate_write_bps))
|
||||||
totalRate = lp->io_rate_read_bps + lp->io_rate_write_bps;
|
totalRate = lp->io_rate_read_bps + lp->io_rate_write_bps;
|
||||||
else if(!isnan(lp->io_rate_read_bps))
|
else if (!isnan(lp->io_rate_read_bps))
|
||||||
totalRate = lp->io_rate_read_bps;
|
totalRate = lp->io_rate_read_bps;
|
||||||
else if(!isnan(lp->io_rate_write_bps))
|
else if (!isnan(lp->io_rate_write_bps))
|
||||||
totalRate = lp->io_rate_write_bps;
|
totalRate = lp->io_rate_write_bps;
|
||||||
else
|
else
|
||||||
totalRate = NAN;
|
totalRate = NAN;
|
||||||
|
|
|
@ -208,7 +208,7 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, ui
|
||||||
|
|
||||||
// Check for /proc/*/smaps_rollup availability (improves smaps parsing speed, Linux 4.14+)
|
// Check for /proc/*/smaps_rollup availability (improves smaps parsing speed, Linux 4.14+)
|
||||||
FILE* file = fopen(PROCDIR "/self/smaps_rollup", "r");
|
FILE* file = fopen(PROCDIR "/self/smaps_rollup", "r");
|
||||||
if(file != NULL) {
|
if (file != NULL) {
|
||||||
this->haveSmapsRollup = true;
|
this->haveSmapsRollup = true;
|
||||||
fclose(file);
|
fclose(file);
|
||||||
} else {
|
} else {
|
||||||
|
@ -271,10 +271,10 @@ void ProcessList_delete(ProcessList* pl) {
|
||||||
|
|
||||||
static inline unsigned long long LinuxProcess_adjustTime(unsigned long long t) {
|
static inline unsigned long long LinuxProcess_adjustTime(unsigned long long t) {
|
||||||
static double jiffy = NAN;
|
static double jiffy = NAN;
|
||||||
if(isnan(jiffy)) {
|
if (isnan(jiffy)) {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
long sc_jiffy = sysconf(_SC_CLK_TCK);
|
long sc_jiffy = sysconf(_SC_CLK_TCK);
|
||||||
if(errno || -1 == sc_jiffy) {
|
if (errno || -1 == sc_jiffy) {
|
||||||
jiffy = NAN;
|
jiffy = NAN;
|
||||||
return t; // Assume 100Hz clock
|
return t; // Assume 100Hz clock
|
||||||
}
|
}
|
||||||
|
@ -481,7 +481,7 @@ static bool LinuxProcessList_readSmapsFile(LinuxProcess* process, const char* di
|
||||||
|
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
|
|
||||||
if(haveSmapsRollup) {// only available in Linux 4.14+
|
if (haveSmapsRollup) {// only available in Linux 4.14+
|
||||||
xSnprintf(buffer, sizeof(buffer), "%s/%s/smaps_rollup", dirname, name);
|
xSnprintf(buffer, sizeof(buffer), "%s/%s/smaps_rollup", dirname, name);
|
||||||
} else {
|
} else {
|
||||||
xSnprintf(buffer, sizeof(buffer), "%s/%s/smaps", dirname, name);
|
xSnprintf(buffer, sizeof(buffer), "%s/%s/smaps", dirname, name);
|
||||||
|
@ -496,10 +496,10 @@ static bool LinuxProcessList_readSmapsFile(LinuxProcess* process, const char* di
|
||||||
process->m_psswp = 0;
|
process->m_psswp = 0;
|
||||||
|
|
||||||
while (fgets(buffer, sizeof(buffer), f)) {
|
while (fgets(buffer, sizeof(buffer), f)) {
|
||||||
if(!strchr(buffer, '\n')) {
|
if (!strchr(buffer, '\n')) {
|
||||||
// Partial line, skip to end of this line
|
// Partial line, skip to end of this line
|
||||||
while (fgets(buffer, sizeof(buffer), f)) {
|
while (fgets(buffer, sizeof(buffer), f)) {
|
||||||
if(strchr(buffer, '\n')) {
|
if (strchr(buffer, '\n')) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -543,10 +543,10 @@ static void LinuxProcessList_readOpenVZData(LinuxProcess* process, const char* d
|
||||||
bool foundVPid = false;
|
bool foundVPid = false;
|
||||||
char linebuf[256];
|
char linebuf[256];
|
||||||
while (fgets(linebuf, sizeof(linebuf), file) != NULL) {
|
while (fgets(linebuf, sizeof(linebuf), file) != NULL) {
|
||||||
if(strchr(linebuf, '\n') == NULL) {
|
if (strchr(linebuf, '\n') == NULL) {
|
||||||
// Partial line, skip to end of this line
|
// Partial line, skip to end of this line
|
||||||
while (fgets(linebuf, sizeof(linebuf), file) != NULL) {
|
while (fgets(linebuf, sizeof(linebuf), file) != NULL) {
|
||||||
if(strchr(linebuf, '\n') != NULL) {
|
if (strchr(linebuf, '\n') != NULL) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -554,14 +554,14 @@ static void LinuxProcessList_readOpenVZData(LinuxProcess* process, const char* d
|
||||||
}
|
}
|
||||||
|
|
||||||
char* name_value_sep = strchr(linebuf, ':');
|
char* name_value_sep = strchr(linebuf, ':');
|
||||||
if(name_value_sep == NULL) {
|
if (name_value_sep == NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int field;
|
int field;
|
||||||
if(0 == strncasecmp(linebuf, "envID", name_value_sep - linebuf)) {
|
if (0 == strncasecmp(linebuf, "envID", name_value_sep - linebuf)) {
|
||||||
field = 1;
|
field = 1;
|
||||||
} else if(0 == strncasecmp(linebuf, "VPid", name_value_sep - linebuf)) {
|
} else if (0 == strncasecmp(linebuf, "VPid", name_value_sep - linebuf)) {
|
||||||
field = 2;
|
field = 2;
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
|
@ -577,7 +577,7 @@ static void LinuxProcessList_readOpenVZData(LinuxProcess* process, const char* d
|
||||||
value_end++;
|
value_end++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(name_value_sep == value_end) {
|
if (name_value_sep == value_end) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -586,7 +586,7 @@ static void LinuxProcessList_readOpenVZData(LinuxProcess* process, const char* d
|
||||||
switch(field) {
|
switch(field) {
|
||||||
case 1:
|
case 1:
|
||||||
foundEnvID = true;
|
foundEnvID = true;
|
||||||
if(!String_eq(name_value_sep, process->ctid ? process->ctid : "")) {
|
if (!String_eq(name_value_sep, process->ctid ? process->ctid : "")) {
|
||||||
free(process->ctid);
|
free(process->ctid);
|
||||||
process->ctid = xStrdup(name_value_sep);
|
process->ctid = xStrdup(name_value_sep);
|
||||||
}
|
}
|
||||||
|
@ -603,12 +603,12 @@ static void LinuxProcessList_readOpenVZData(LinuxProcess* process, const char* d
|
||||||
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
if(!foundEnvID) {
|
if (!foundEnvID) {
|
||||||
free(process->ctid);
|
free(process->ctid);
|
||||||
process->ctid = NULL;
|
process->ctid = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!foundVPid) {
|
if (!foundVPid) {
|
||||||
process->vpid = process->super.pid;
|
process->vpid = process->super.pid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1010,7 +1010,7 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, const char*
|
||||||
if (isnan(proc->percent_cpu)) proc->percent_cpu = 0.0;
|
if (isnan(proc->percent_cpu)) proc->percent_cpu = 0.0;
|
||||||
proc->percent_mem = (proc->m_resident * CRT_pageSizeKB) / (double)(pl->totalMem) * 100.0;
|
proc->percent_mem = (proc->m_resident * CRT_pageSizeKB) / (double)(pl->totalMem) * 100.0;
|
||||||
|
|
||||||
if(!preExisting) {
|
if (!preExisting) {
|
||||||
|
|
||||||
if (! LinuxProcessList_statProcessDir(proc, dirname, name))
|
if (! LinuxProcessList_statProcessDir(proc, dirname, name))
|
||||||
goto errorReadingProcess;
|
goto errorReadingProcess;
|
||||||
|
|
|
@ -272,7 +272,7 @@ char* Platform_getProcessEnv(pid_t pid) {
|
||||||
char procname[128];
|
char procname[128];
|
||||||
xSnprintf(procname, sizeof(procname), PROCDIR "/%d/environ", pid);
|
xSnprintf(procname, sizeof(procname), PROCDIR "/%d/environ", pid);
|
||||||
FILE* fd = fopen(procname, "r");
|
FILE* fd = fopen(procname, "r");
|
||||||
if(!fd)
|
if (!fd)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
char *env = NULL;
|
char *env = NULL;
|
||||||
|
|
|
@ -19,18 +19,18 @@ static void ZramMeter_updateValues(Meter* this, char* buffer, int size) {
|
||||||
written = Meter_humanUnit(buffer, this->values[0], size);
|
written = Meter_humanUnit(buffer, this->values[0], size);
|
||||||
buffer += written;
|
buffer += written;
|
||||||
size -= written;
|
size -= written;
|
||||||
if(size <= 0) {
|
if (size <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
*buffer++ = '(';
|
*buffer++ = '(';
|
||||||
size--;
|
size--;
|
||||||
if(size <= 0) {
|
if (size <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
written = Meter_humanUnit(buffer, this->values[1], size);
|
written = Meter_humanUnit(buffer, this->values[1], size);
|
||||||
buffer += written;
|
buffer += written;
|
||||||
size -= written;
|
size -= written;
|
||||||
if(size <= 0) {
|
if (size <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
*buffer++ = ')';
|
*buffer++ = ')';
|
||||||
|
|
|
@ -322,7 +322,7 @@ int SolarisProcessList_walkproc(psinfo_t *_psinfo, lwpsinfo_t *_lwpsinfo, void *
|
||||||
// See note above (in common section) about this BINARY FRACTION
|
// See note above (in common section) about this BINARY FRACTION
|
||||||
proc->percent_cpu = ((uint16_t)_psinfo->pr_pctcpu/(double)32768)*(double)100.0;
|
proc->percent_cpu = ((uint16_t)_psinfo->pr_pctcpu/(double)32768)*(double)100.0;
|
||||||
proc->time = _psinfo->pr_time.tv_sec;
|
proc->time = _psinfo->pr_time.tv_sec;
|
||||||
if(!preExisting) { // Tasks done only for NEW processes
|
if (!preExisting) { // Tasks done only for NEW processes
|
||||||
sproc->is_lwp = false;
|
sproc->is_lwp = false;
|
||||||
proc->starttime_ctime = _psinfo->pr_start.tv_sec;
|
proc->starttime_ctime = _psinfo->pr_start.tv_sec;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue