From 02431c43e1db2ab18769dc1f0bcfa52e8219f81a Mon Sep 17 00:00:00 2001 From: Benny Baumann Date: Sat, 19 Dec 2020 16:21:08 +0100 Subject: [PATCH] Rename command line field from comm to cmdline --- Process.c | 14 +++++++------- Process.h | 4 ++-- ProcessList.c | 2 +- darwin/DarwinProcess.c | 2 +- dragonflybsd/DragonFlyBSDProcessList.c | 6 +++--- freebsd/FreeBSDProcessList.c | 6 +++--- linux/LinuxProcess.c | 4 ++-- linux/LinuxProcessList.c | 8 ++++---- openbsd/OpenBSDProcessList.c | 6 +++--- solaris/SolarisProcessList.c | 2 +- unsupported/UnsupportedProcessList.c | 2 +- 11 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Process.c b/Process.c index 01c08b88..070f7e57 100644 --- a/Process.c +++ b/Process.c @@ -255,14 +255,14 @@ void Process_fillStarttimeBuffer(Process* this) { static inline void Process_writeCommand(const Process* this, int attr, int baseattr, RichString* str) { int start = RichString_size(str); int len = 0; - const char* comm = this->comm; + const char* cmdline = this->cmdline; if (this->settings->highlightBaseName || !this->settings->showProgramPath) { int basename = 0; for (int i = 0; i < this->basenameOffset; i++) { - if (comm[i] == '/') { + if (cmdline[i] == '/') { basename = i + 1; - } else if (comm[i] == ':') { + } else if (cmdline[i] == ':') { len = i + 1; break; } @@ -271,13 +271,13 @@ static inline void Process_writeCommand(const Process* this, int attr, int basea if (this->settings->showProgramPath) { start += basename; } else { - comm += basename; + cmdline += basename; } len = this->basenameOffset - basename; } } - RichString_appendWide(str, attr, comm); + RichString_appendWide(str, attr, cmdline); if (this->settings->highlightBaseName) { RichString_setAttrn(str, baseattr, start, len); @@ -514,12 +514,12 @@ void Process_display(const Object* cast, RichString* out) { void Process_done(Process* this) { assert (this != NULL); - free(this->comm); + free(this->cmdline); free(this->tty_name); } static const char* Process_getCommandStr(const Process* p) { - return p->comm ? p->comm : ""; + return p->cmdline ? p->cmdline : ""; } const ProcessClass Process_class = { diff --git a/Process.h b/Process.h index b4d80b9e..47096853 100644 --- a/Process.h +++ b/Process.h @@ -100,7 +100,7 @@ typedef struct Process_ { * Process name including arguments. * Use Process_getCommand() for Command actually displayed. */ - char* comm; + char* cmdline; /* Offset in comm of the process basename */ int basenameOffset; @@ -230,7 +230,7 @@ typedef struct ProcessClass_ { #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_)) static inline pid_t Process_getParentPid(const Process* this) { diff --git a/ProcessList.c b/ProcessList.c index 8c82cbfc..4905f4f5 100644 --- a/ProcessList.c +++ b/ProcessList.c @@ -569,7 +569,7 @@ Process* ProcessList_getProcess(ProcessList* this, pid_t pid, bool* preExisting, assert(proc->pid == pid); } else { proc = constructor(this->settings); - assert(proc->comm == NULL); + assert(proc->cmdline == NULL); proc->pid = pid; } return proc; diff --git a/darwin/DarwinProcess.c b/darwin/DarwinProcess.c index 9287641e..d94203c7 100644 --- a/darwin/DarwinProcess.c +++ b/darwin/DarwinProcess.c @@ -286,7 +286,7 @@ void DarwinProcess_setFromKInfoProc(Process* proc, const struct kinfo_proc* ps, proc->starttime_ctime = ep->p_starttime.tv_sec; Process_fillStarttimeBuffer(proc); - proc->comm = DarwinProcess_getCmdLine(ps, &(proc->basenameOffset)); + proc->cmdline = DarwinProcess_getCmdLine(ps, &(proc->basenameOffset)); } /* Mutable information */ diff --git a/dragonflybsd/DragonFlyBSDProcessList.c b/dragonflybsd/DragonFlyBSDProcessList.c index 42245e22..16ee37a9 100644 --- a/dragonflybsd/DragonFlyBSDProcessList.c +++ b/dragonflybsd/DragonFlyBSDProcessList.c @@ -417,7 +417,7 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) { } 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); } else { 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); } if (settings->updateProcessNames) { - free(proc->comm); - proc->comm = DragonFlyBSDProcessList_readProcessName(dfpl->kd, kproc, &proc->basenameOffset); + free(proc->cmdline); + proc->cmdline = DragonFlyBSDProcessList_readProcessName(dfpl->kd, kproc, &proc->basenameOffset); } } diff --git a/freebsd/FreeBSDProcessList.c b/freebsd/FreeBSDProcessList.c index 92fdd3dd..0d5e4565 100644 --- a/freebsd/FreeBSDProcessList.c +++ b/freebsd/FreeBSDProcessList.c @@ -467,7 +467,7 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) { Process_fillStarttimeBuffer(proc); proc->user = UsersTable_getRef(super->usersTable, proc->st_uid); 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); 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); } if (settings->updateProcessNames) { - free(proc->comm); - proc->comm = FreeBSDProcessList_readProcessName(fpl->kd, kproc, &proc->basenameOffset); + free(proc->cmdline); + proc->cmdline = FreeBSDProcessList_readProcessName(fpl->kd, kproc, &proc->basenameOffset); } } diff --git a/linux/LinuxProcess.c b/linux/LinuxProcess.c index bd9dc89d..230a7271 100644 --- a/linux/LinuxProcess.c +++ b/linux/LinuxProcess.c @@ -110,7 +110,7 @@ const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = { static const char* LinuxProcess_getCommandStr(const Process *this) { const LinuxProcess *lp = (const LinuxProcess *)this; if ((Process_isUserlandThread(this) && this->settings->showThreadNames) || !lp->mergedCommand.str) { - return this->comm; + return this->cmdline; } return lp->mergedCommand.str; } @@ -386,7 +386,7 @@ void LinuxProcess_makeCommandStr(Process* this) { const int delAttr = CRT_colors[FAILED_READ]; /* Establish some shortcuts to data we need */ - const char *cmdline = this->comm; + const char *cmdline = this->cmdline; const char *procExe = lp->procExe; const char *procComm = lp->procComm; diff --git a/linux/LinuxProcessList.c b/linux/LinuxProcessList.c index 51999d1a..24cb6ee1 100644 --- a/linux/LinuxProcessList.c +++ b/linux/LinuxProcessList.c @@ -1132,9 +1132,9 @@ static bool LinuxProcessList_readCmdlineFile(Process* process, openat_arg_t proc LinuxProcess *lp = (LinuxProcess *)process; 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; - free_and_xStrdup(&process->comm, command); + free_and_xStrdup(&process->cmdline, command); lp->procCmdlineBasenameOffset = tokenStart; lp->procCmdlineBasenameEnd = tokenEnd; lp->mergedCommand.cmdlineChanged = true; @@ -1458,14 +1458,14 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, openat_arg_ if (proc->state == 'Z' && (proc->basenameOffset == 0)) { proc->basenameOffset = -1; - free_and_xStrdup(&proc->comm, command); + free_and_xStrdup(&proc->cmdline, command); lp->procCmdlineBasenameOffset = 0; lp->procCmdlineBasenameEnd = 0; lp->mergedCommand.commChanged = true; } else if (Process_isThread(proc)) { if (settings->showThreadNames || Process_isKernelThread(proc)) { proc->basenameOffset = -1; - free_and_xStrdup(&proc->comm, command); + free_and_xStrdup(&proc->cmdline, command); lp->procCmdlineBasenameOffset = 0; lp->procCmdlineBasenameEnd = 0; lp->mergedCommand.commChanged = true; diff --git a/openbsd/OpenBSDProcessList.c b/openbsd/OpenBSDProcessList.c index 67d4da1f..9ad13c8f 100644 --- a/openbsd/OpenBSDProcessList.c +++ b/openbsd/OpenBSDProcessList.c @@ -257,7 +257,7 @@ static void OpenBSDProcessList_scanProcs(OpenBSDProcessList* this) { Process_fillStarttimeBuffer(proc); proc->user = UsersTable_getRef(this->super.usersTable, proc->st_uid); 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; 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 { if (settings->updateProcessNames) { - free(proc->comm); - proc->comm = OpenBSDProcessList_readProcessName(this->kd, kproc, &proc->basenameOffset); + free(proc->cmdline); + proc->cmdline = OpenBSDProcessList_readProcessName(this->kd, kproc, &proc->basenameOffset); } } diff --git a/solaris/SolarisProcessList.c b/solaris/SolarisProcessList.c index a448cd4a..8d9cf639 100644 --- a/solaris/SolarisProcessList.c +++ b/solaris/SolarisProcessList.c @@ -362,7 +362,7 @@ static int SolarisProcessList_walkproc(psinfo_t* _psinfo, lwpsinfo_t* _lwpsinfo, sproc->zoneid = _psinfo->pr_zoneid; sproc->zname = SolarisProcessList_readZoneName(spl->kd, sproc); 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 diff --git a/unsupported/UnsupportedProcessList.c b/unsupported/UnsupportedProcessList.c index 81031487..4323a26f 100644 --- a/unsupported/UnsupportedProcessList.c +++ b/unsupported/UnsupportedProcessList.c @@ -45,7 +45,7 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) { proc->pid = 1; proc->ppid = 1; proc->tgid = 0; - free_and_xStrdup(&proc->comm, ""); + free_and_xStrdup(&proc->cmdline, ""); proc->basenameOffset = 0; proc->updated = true;