mirror of https://github.com/xzeldon/htop.git
Rename command line field from comm to cmdline
This commit is contained in:
parent
fbec3e4005
commit
02431c43e1
14
Process.c
14
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 = {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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, "<unsupported architecture>");
|
||||
free_and_xStrdup(&proc->cmdline, "<unsupported architecture>");
|
||||
proc->basenameOffset = 0;
|
||||
proc->updated = true;
|
||||
|
||||
|
|
Loading…
Reference in New Issue