Rename command line field from comm to cmdline

This commit is contained in:
Benny Baumann 2020-12-19 16:21:08 +01:00 committed by BenBE
parent fbec3e4005
commit 02431c43e1
11 changed files with 28 additions and 28 deletions

View File

@ -255,14 +255,14 @@ void Process_fillStarttimeBuffer(Process* this) {
static inline void Process_writeCommand(const Process* this, int attr, int baseattr, RichString* str) { static inline void Process_writeCommand(const Process* this, int attr, int baseattr, RichString* str) {
int start = RichString_size(str); int start = RichString_size(str);
int len = 0; int len = 0;
const char* comm = this->comm; const char* cmdline = this->cmdline;
if (this->settings->highlightBaseName || !this->settings->showProgramPath) { if (this->settings->highlightBaseName || !this->settings->showProgramPath) {
int basename = 0; int basename = 0;
for (int i = 0; i < this->basenameOffset; i++) { for (int i = 0; i < this->basenameOffset; i++) {
if (comm[i] == '/') { if (cmdline[i] == '/') {
basename = i + 1; basename = i + 1;
} else if (comm[i] == ':') { } else if (cmdline[i] == ':') {
len = i + 1; len = i + 1;
break; break;
} }
@ -271,13 +271,13 @@ static inline void Process_writeCommand(const Process* this, int attr, int basea
if (this->settings->showProgramPath) { if (this->settings->showProgramPath) {
start += basename; start += basename;
} else { } else {
comm += basename; cmdline += basename;
} }
len = this->basenameOffset - basename; len = this->basenameOffset - basename;
} }
} }
RichString_appendWide(str, attr, comm); RichString_appendWide(str, attr, cmdline);
if (this->settings->highlightBaseName) { if (this->settings->highlightBaseName) {
RichString_setAttrn(str, baseattr, start, len); RichString_setAttrn(str, baseattr, start, len);
@ -514,12 +514,12 @@ void Process_display(const Object* cast, RichString* out) {
void Process_done(Process* this) { void Process_done(Process* this) {
assert (this != NULL); assert (this != NULL);
free(this->comm); free(this->cmdline);
free(this->tty_name); free(this->tty_name);
} }
static const char* Process_getCommandStr(const Process* p) { static const char* Process_getCommandStr(const Process* p) {
return p->comm ? p->comm : ""; return p->cmdline ? p->cmdline : "";
} }
const ProcessClass Process_class = { const ProcessClass Process_class = {

View File

@ -100,7 +100,7 @@ typedef struct Process_ {
* Process name including arguments. * Process name including arguments.
* Use Process_getCommand() for Command actually displayed. * Use Process_getCommand() for Command actually displayed.
*/ */
char* comm; char* cmdline;
/* Offset in comm of the process basename */ /* Offset in comm of the process basename */
int basenameOffset; int basenameOffset;
@ -230,7 +230,7 @@ typedef struct ProcessClass_ {
#define As_Process(this_) ((const ProcessClass*)((this_)->super.klass)) #define As_Process(this_) ((const ProcessClass*)((this_)->super.klass))
#define Process_getCommand(this_) (As_Process(this_)->getCommandStr ? As_Process(this_)->getCommandStr((const Process*)(this_)) : ((const Process*)(this_))->comm) #define Process_getCommand(this_) (As_Process(this_)->getCommandStr ? As_Process(this_)->getCommandStr((const Process*)(this_)) : ((const Process*)(this_))->cmdline)
#define Process_compareByKey(p1_, p2_, key_) (As_Process(p1_)->compareByKey ? (As_Process(p1_)->compareByKey(p1_, p2_, key_)) : Process_compareByKey_Base(p1_, p2_, key_)) #define Process_compareByKey(p1_, p2_, key_) (As_Process(p1_)->compareByKey ? (As_Process(p1_)->compareByKey(p1_, p2_, key_)) : Process_compareByKey_Base(p1_, p2_, key_))
static inline pid_t Process_getParentPid(const Process* this) { static inline pid_t Process_getParentPid(const Process* this) {

View File

@ -569,7 +569,7 @@ Process* ProcessList_getProcess(ProcessList* this, pid_t pid, bool* preExisting,
assert(proc->pid == pid); assert(proc->pid == pid);
} else { } else {
proc = constructor(this->settings); proc = constructor(this->settings);
assert(proc->comm == NULL); assert(proc->cmdline == NULL);
proc->pid = pid; proc->pid = pid;
} }
return proc; return proc;

View File

@ -286,7 +286,7 @@ void DarwinProcess_setFromKInfoProc(Process* proc, const struct kinfo_proc* ps,
proc->starttime_ctime = ep->p_starttime.tv_sec; proc->starttime_ctime = ep->p_starttime.tv_sec;
Process_fillStarttimeBuffer(proc); Process_fillStarttimeBuffer(proc);
proc->comm = DarwinProcess_getCmdLine(ps, &(proc->basenameOffset)); proc->cmdline = DarwinProcess_getCmdLine(ps, &(proc->basenameOffset));
} }
/* Mutable information */ /* Mutable information */

View File

@ -417,7 +417,7 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
} }
ProcessList_add(super, proc); ProcessList_add(super, proc);
proc->comm = DragonFlyBSDProcessList_readProcessName(dfpl->kd, kproc, &proc->basenameOffset); proc->cmdline = DragonFlyBSDProcessList_readProcessName(dfpl->kd, kproc, &proc->basenameOffset);
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;
@ -433,8 +433,8 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
proc->user = UsersTable_getRef(super->usersTable, proc->st_uid); proc->user = UsersTable_getRef(super->usersTable, proc->st_uid);
} }
if (settings->updateProcessNames) { if (settings->updateProcessNames) {
free(proc->comm); free(proc->cmdline);
proc->comm = DragonFlyBSDProcessList_readProcessName(dfpl->kd, kproc, &proc->basenameOffset); proc->cmdline = DragonFlyBSDProcessList_readProcessName(dfpl->kd, kproc, &proc->basenameOffset);
} }
} }

View File

@ -467,7 +467,7 @@ 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->comm = FreeBSDProcessList_readProcessName(fpl->kd, kproc, &proc->basenameOffset); proc->cmdline = FreeBSDProcessList_readProcessName(fpl->kd, kproc, &proc->basenameOffset);
fp->jname = FreeBSDProcessList_readJailName(kproc); fp->jname = FreeBSDProcessList_readJailName(kproc);
proc->tty_nr = kproc->ki_tdev; proc->tty_nr = kproc->ki_tdev;
@ -493,8 +493,8 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
proc->user = UsersTable_getRef(super->usersTable, proc->st_uid); proc->user = UsersTable_getRef(super->usersTable, proc->st_uid);
} }
if (settings->updateProcessNames) { if (settings->updateProcessNames) {
free(proc->comm); free(proc->cmdline);
proc->comm = FreeBSDProcessList_readProcessName(fpl->kd, kproc, &proc->basenameOffset); proc->cmdline = FreeBSDProcessList_readProcessName(fpl->kd, kproc, &proc->basenameOffset);
} }
} }

View File

@ -110,7 +110,7 @@ const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
static const char* LinuxProcess_getCommandStr(const Process *this) { static const char* LinuxProcess_getCommandStr(const Process *this) {
const LinuxProcess *lp = (const LinuxProcess *)this; const LinuxProcess *lp = (const LinuxProcess *)this;
if ((Process_isUserlandThread(this) && this->settings->showThreadNames) || !lp->mergedCommand.str) { if ((Process_isUserlandThread(this) && this->settings->showThreadNames) || !lp->mergedCommand.str) {
return this->comm; return this->cmdline;
} }
return lp->mergedCommand.str; return lp->mergedCommand.str;
} }
@ -386,7 +386,7 @@ void LinuxProcess_makeCommandStr(Process* this) {
const int delAttr = CRT_colors[FAILED_READ]; const int delAttr = CRT_colors[FAILED_READ];
/* Establish some shortcuts to data we need */ /* Establish some shortcuts to data we need */
const char *cmdline = this->comm; const char *cmdline = this->cmdline;
const char *procExe = lp->procExe; const char *procExe = lp->procExe;
const char *procComm = lp->procComm; const char *procComm = lp->procComm;

View File

@ -1132,9 +1132,9 @@ static bool LinuxProcessList_readCmdlineFile(Process* process, openat_arg_t proc
LinuxProcess *lp = (LinuxProcess *)process; LinuxProcess *lp = (LinuxProcess *)process;
lp->mergedCommand.maxLen = lastChar + 1; /* accommodate cmdline */ lp->mergedCommand.maxLen = lastChar + 1; /* accommodate cmdline */
if (!process->comm || !String_eq(command, process->comm)) { if (!process->cmdline || !String_eq(command, process->cmdline)) {
process->basenameOffset = tokenEnd; process->basenameOffset = tokenEnd;
free_and_xStrdup(&process->comm, command); free_and_xStrdup(&process->cmdline, command);
lp->procCmdlineBasenameOffset = tokenStart; lp->procCmdlineBasenameOffset = tokenStart;
lp->procCmdlineBasenameEnd = tokenEnd; lp->procCmdlineBasenameEnd = tokenEnd;
lp->mergedCommand.cmdlineChanged = true; lp->mergedCommand.cmdlineChanged = true;
@ -1458,14 +1458,14 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, openat_arg_
if (proc->state == 'Z' && (proc->basenameOffset == 0)) { if (proc->state == 'Z' && (proc->basenameOffset == 0)) {
proc->basenameOffset = -1; proc->basenameOffset = -1;
free_and_xStrdup(&proc->comm, command); free_and_xStrdup(&proc->cmdline, command);
lp->procCmdlineBasenameOffset = 0; lp->procCmdlineBasenameOffset = 0;
lp->procCmdlineBasenameEnd = 0; lp->procCmdlineBasenameEnd = 0;
lp->mergedCommand.commChanged = true; lp->mergedCommand.commChanged = true;
} else if (Process_isThread(proc)) { } else if (Process_isThread(proc)) {
if (settings->showThreadNames || Process_isKernelThread(proc)) { if (settings->showThreadNames || Process_isKernelThread(proc)) {
proc->basenameOffset = -1; proc->basenameOffset = -1;
free_and_xStrdup(&proc->comm, command); free_and_xStrdup(&proc->cmdline, command);
lp->procCmdlineBasenameOffset = 0; lp->procCmdlineBasenameOffset = 0;
lp->procCmdlineBasenameEnd = 0; lp->procCmdlineBasenameEnd = 0;
lp->mergedCommand.commChanged = true; lp->mergedCommand.commChanged = true;

View File

@ -257,7 +257,7 @@ 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->comm = OpenBSDProcessList_readProcessName(this->kd, kproc, &proc->basenameOffset); proc->cmdline = OpenBSDProcessList_readProcessName(this->kd, kproc, &proc->basenameOffset);
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;
@ -269,8 +269,8 @@ static void OpenBSDProcessList_scanProcs(OpenBSDProcessList* this) {
} }
} else { } else {
if (settings->updateProcessNames) { if (settings->updateProcessNames) {
free(proc->comm); free(proc->cmdline);
proc->comm = OpenBSDProcessList_readProcessName(this->kd, kproc, &proc->basenameOffset); proc->cmdline = OpenBSDProcessList_readProcessName(this->kd, kproc, &proc->basenameOffset);
} }
} }

View File

@ -362,7 +362,7 @@ static int SolarisProcessList_walkproc(psinfo_t* _psinfo, lwpsinfo_t* _lwpsinfo,
sproc->zoneid = _psinfo->pr_zoneid; sproc->zoneid = _psinfo->pr_zoneid;
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->comm = xStrdup(_psinfo->pr_fname); proc->cmdline = xStrdup(_psinfo->pr_fname);
} }
// End common code pass 1 // End common code pass 1

View File

@ -45,7 +45,7 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
proc->pid = 1; proc->pid = 1;
proc->ppid = 1; proc->ppid = 1;
proc->tgid = 0; proc->tgid = 0;
free_and_xStrdup(&proc->comm, "<unsupported architecture>"); free_and_xStrdup(&proc->cmdline, "<unsupported architecture>");
proc->basenameOffset = 0; proc->basenameOffset = 0;
proc->updated = true; proc->updated = true;