mirror of
https://github.com/xzeldon/htop.git
synced 2024-12-24 23:15:46 +00:00
Call makeCommandStr on all platforms
This commit is contained in:
parent
bcb18ef822
commit
a61a2e6d47
11
Process.c
11
Process.c
@ -388,6 +388,17 @@ void Process_makeCommandStr(Process *this) {
|
|||||||
bool searchCommInCmdline = settings->findCommInCmdline;
|
bool searchCommInCmdline = settings->findCommInCmdline;
|
||||||
bool stripExeFromCmdline = settings->stripExeFromCmdline;
|
bool stripExeFromCmdline = settings->stripExeFromCmdline;
|
||||||
|
|
||||||
|
/* Nothing to do to (Re)Generate the Command string, if the process is:
|
||||||
|
* - a kernel thread, or
|
||||||
|
* - a zombie from before being under htop's watch, or
|
||||||
|
* - a user thread and showThreadNames is not set */
|
||||||
|
if (Process_isKernelThread(this))
|
||||||
|
return;
|
||||||
|
if (this->state == 'Z' && !this->mergedCommand.str)
|
||||||
|
return;
|
||||||
|
if (Process_isUserlandThread(this) && settings->showThreadNames)
|
||||||
|
return;
|
||||||
|
|
||||||
/* this->mergedCommand.str needs updating only if its state or contents changed.
|
/* this->mergedCommand.str needs updating only if its state or contents changed.
|
||||||
* Its content is based on the fields cmdline, comm, and exe. */
|
* Its content is based on the fields cmdline, comm, and exe. */
|
||||||
if (
|
if (
|
||||||
|
@ -609,6 +609,8 @@ void ProcessList_scan(ProcessList* this, bool pauseProcessUpdate) {
|
|||||||
|
|
||||||
for (int i = Vector_size(this->processes) - 1; i >= 0; i--) {
|
for (int i = Vector_size(this->processes) - 1; i >= 0; i--) {
|
||||||
Process* p = (Process*) Vector_get(this->processes, i);
|
Process* p = (Process*) Vector_get(this->processes, i);
|
||||||
|
Process_makeCommandStr(p);
|
||||||
|
|
||||||
if (p->tombStampMs > 0) {
|
if (p->tombStampMs > 0) {
|
||||||
// remove tombed process
|
// remove tombed process
|
||||||
if (this->monotonicMs >= p->tombStampMs) {
|
if (this->monotonicMs >= p->tombStampMs) {
|
||||||
@ -623,8 +625,6 @@ void ProcessList_scan(ProcessList* this, bool pauseProcessUpdate) {
|
|||||||
// immediately remove
|
// immediately remove
|
||||||
ProcessList_remove(this, p);
|
ProcessList_remove(this, p);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
p->updated = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,6 +285,7 @@ void DarwinProcess_setFromKInfoProc(Process* proc, const struct kinfo_proc* ps,
|
|||||||
Process_fillStarttimeBuffer(proc);
|
Process_fillStarttimeBuffer(proc);
|
||||||
|
|
||||||
proc->cmdline = DarwinProcess_getCmdLine(ps, &proc->cmdlineBasenameEnd);
|
proc->cmdline = DarwinProcess_getCmdLine(ps, &proc->cmdlineBasenameEnd);
|
||||||
|
proc->mergedCommand.cmdlineChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Mutable information */
|
/* Mutable information */
|
||||||
|
@ -419,6 +419,8 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
|
|||||||
|
|
||||||
ProcessList_add(super, proc);
|
ProcessList_add(super, proc);
|
||||||
proc->cmdline = DragonFlyBSDProcessList_readProcessName(dfpl->kd, kproc, &proc->cmdlineBasenameEnd);
|
proc->cmdline = DragonFlyBSDProcessList_readProcessName(dfpl->kd, kproc, &proc->cmdlineBasenameEnd);
|
||||||
|
proc->mergedCommand.cmdlineChanged = true;
|
||||||
|
|
||||||
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;
|
||||||
@ -436,6 +438,7 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
|
|||||||
if (settings->updateProcessNames) {
|
if (settings->updateProcessNames) {
|
||||||
free(proc->cmdline);
|
free(proc->cmdline);
|
||||||
proc->cmdline = DragonFlyBSDProcessList_readProcessName(dfpl->kd, kproc, &proc->cmdlineBasenameEnd);
|
proc->cmdline = DragonFlyBSDProcessList_readProcessName(dfpl->kd, kproc, &proc->cmdlineBasenameEnd);
|
||||||
|
proc->mergedCommand.cmdlineChanged = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -468,7 +468,10 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
|
|||||||
Process_fillStarttimeBuffer(proc);
|
Process_fillStarttimeBuffer(proc);
|
||||||
proc->user = UsersTable_getRef(super->usersTable, proc->st_uid);
|
proc->user = UsersTable_getRef(super->usersTable, proc->st_uid);
|
||||||
ProcessList_add(super, proc);
|
ProcessList_add(super, proc);
|
||||||
|
|
||||||
proc->cmdline = FreeBSDProcessList_readProcessName(fpl->kd, kproc, &proc->cmdlineBasenameEnd);
|
proc->cmdline = FreeBSDProcessList_readProcessName(fpl->kd, kproc, &proc->cmdlineBasenameEnd);
|
||||||
|
proc->mergedCommand.cmdlineChanged = true;
|
||||||
|
|
||||||
fp->jname = FreeBSDProcessList_readJailName(kproc);
|
fp->jname = FreeBSDProcessList_readJailName(kproc);
|
||||||
|
|
||||||
proc->tty_nr = kproc->ki_tdev;
|
proc->tty_nr = kproc->ki_tdev;
|
||||||
@ -496,6 +499,7 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
|
|||||||
if (settings->updateProcessNames) {
|
if (settings->updateProcessNames) {
|
||||||
free(proc->cmdline);
|
free(proc->cmdline);
|
||||||
proc->cmdline = FreeBSDProcessList_readProcessName(fpl->kd, kproc, &proc->cmdlineBasenameEnd);
|
proc->cmdline = FreeBSDProcessList_readProcessName(fpl->kd, kproc, &proc->cmdlineBasenameEnd);
|
||||||
|
proc->mergedCommand.cmdlineChanged = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1425,15 +1425,6 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, openat_arg_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* (Re)Generate the Command string, but only if the process is:
|
|
||||||
* - not a kernel thread, and
|
|
||||||
* - not a zombie or it became zombie under htop's watch, and
|
|
||||||
* - not a user thread or if showThreadNames is not set */
|
|
||||||
if (!Process_isKernelThread(proc) &&
|
|
||||||
(proc->state != 'Z' || proc->mergedCommand.str) &&
|
|
||||||
(!Process_isUserlandThread(proc) || !settings->showThreadNames)) {
|
|
||||||
Process_makeCommandStr(proc);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HAVE_DELAYACCT
|
#ifdef HAVE_DELAYACCT
|
||||||
if (settings->flags & PROCESS_FLAG_LINUX_DELAYACCT) {
|
if (settings->flags & PROCESS_FLAG_LINUX_DELAYACCT) {
|
||||||
|
@ -259,7 +259,9 @@ static void OpenBSDProcessList_scanProcs(OpenBSDProcessList* this) {
|
|||||||
Process_fillStarttimeBuffer(proc);
|
Process_fillStarttimeBuffer(proc);
|
||||||
proc->user = UsersTable_getRef(this->super.usersTable, proc->st_uid);
|
proc->user = UsersTable_getRef(this->super.usersTable, proc->st_uid);
|
||||||
ProcessList_add(&this->super, proc);
|
ProcessList_add(&this->super, proc);
|
||||||
|
|
||||||
proc->cmdline = OpenBSDProcessList_readProcessName(this->kd, kproc, &proc->cmdlineBasenameEnd);
|
proc->cmdline = OpenBSDProcessList_readProcessName(this->kd, kproc, &proc->cmdlineBasenameEnd);
|
||||||
|
proc->mergedCommand.cmdlineChanged = true;
|
||||||
|
|
||||||
proc->tty_nr = kproc->p_tdev;
|
proc->tty_nr = kproc->p_tdev;
|
||||||
const char* name = ((dev_t)kproc->p_tdev != NODEV) ? devname(kproc->p_tdev, S_IFCHR) : NULL;
|
const char* name = ((dev_t)kproc->p_tdev != NODEV) ? devname(kproc->p_tdev, S_IFCHR) : NULL;
|
||||||
@ -273,6 +275,7 @@ static void OpenBSDProcessList_scanProcs(OpenBSDProcessList* this) {
|
|||||||
if (settings->updateProcessNames) {
|
if (settings->updateProcessNames) {
|
||||||
free(proc->cmdline);
|
free(proc->cmdline);
|
||||||
proc->cmdline = OpenBSDProcessList_readProcessName(this->kd, kproc, &proc->cmdlineBasenameEnd);
|
proc->cmdline = OpenBSDProcessList_readProcessName(this->kd, kproc, &proc->cmdlineBasenameEnd);
|
||||||
|
proc->mergedCommand.cmdlineChanged = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,6 +364,7 @@ static int SolarisProcessList_walkproc(psinfo_t* _psinfo, lwpsinfo_t* _lwpsinfo,
|
|||||||
sproc->zname = SolarisProcessList_readZoneName(spl->kd, sproc);
|
sproc->zname = SolarisProcessList_readZoneName(spl->kd, sproc);
|
||||||
proc->user = UsersTable_getRef(pl->usersTable, proc->st_uid);
|
proc->user = UsersTable_getRef(pl->usersTable, proc->st_uid);
|
||||||
proc->cmdline = xStrdup(_psinfo->pr_fname);
|
proc->cmdline = xStrdup(_psinfo->pr_fname);
|
||||||
|
proc->mergedCommand.cmdlineChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// End common code pass 1
|
// End common code pass 1
|
||||||
@ -411,6 +412,7 @@ static int SolarisProcessList_walkproc(psinfo_t* _psinfo, lwpsinfo_t* _lwpsinfo,
|
|||||||
sproc->realppid = _psinfo->pr_pid;
|
sproc->realppid = _psinfo->pr_pid;
|
||||||
sproc->realtgid = _psinfo->pr_pid;
|
sproc->realtgid = _psinfo->pr_pid;
|
||||||
proc->starttime_ctime = _lwpsinfo->pr_start.tv_sec;
|
proc->starttime_ctime = _lwpsinfo->pr_start.tv_sec;
|
||||||
|
proc->mergedCommand.cmdlineChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Top-level process only gets this for the representative LWP
|
// Top-level process only gets this for the representative LWP
|
||||||
@ -434,6 +436,7 @@ static int SolarisProcessList_walkproc(psinfo_t* _psinfo, lwpsinfo_t* _lwpsinfo,
|
|||||||
Process_fillStarttimeBuffer(proc);
|
Process_fillStarttimeBuffer(proc);
|
||||||
ProcessList_add(pl, proc);
|
ProcessList_add(pl, proc);
|
||||||
}
|
}
|
||||||
|
|
||||||
proc->updated = true;
|
proc->updated = true;
|
||||||
|
|
||||||
// End common code pass 2
|
// End common code pass 2
|
||||||
|
@ -47,6 +47,7 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
|
|||||||
proc->tgid = 0;
|
proc->tgid = 0;
|
||||||
free_and_xStrdup(&proc->cmdline, "<unsupported architecture>");
|
free_and_xStrdup(&proc->cmdline, "<unsupported architecture>");
|
||||||
proc->cmdlineBasenameEnd = -1;
|
proc->cmdlineBasenameEnd = -1;
|
||||||
|
proc->mergedCommand.cmdlineChanged = true;
|
||||||
proc->updated = true;
|
proc->updated = true;
|
||||||
|
|
||||||
proc->state = 'R';
|
proc->state = 'R';
|
||||||
|
Loading…
Reference in New Issue
Block a user