mirror of https://github.com/xzeldon/htop.git
Move LinuxProcess_getCommandStr to Process_getCommandStr
This commit is contained in:
parent
7224d0e083
commit
c0d0202440
11
Process.c
11
Process.c
|
@ -521,8 +521,15 @@ void Process_done(Process* this) {
|
||||||
free(this->tty_name);
|
free(this->tty_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* Process_getCommandStr(const Process* p) {
|
/* This function returns the string displayed in Command column, so that sorting
|
||||||
return p->cmdline ? p->cmdline : "";
|
* happens on what is displayed - whether comm, full path, basename, etc.. So
|
||||||
|
* this follows Process_writeField(COMM) and Process_writeCommand */
|
||||||
|
const char *Process_getCommandStr(const Process *this) {
|
||||||
|
if ((Process_isUserlandThread(this) && this->settings->showThreadNames) || !this->mergedCommand.str) {
|
||||||
|
return this->cmdline;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this->mergedCommand.str;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ProcessClass Process_class = {
|
const ProcessClass Process_class = {
|
||||||
|
|
|
@ -284,7 +284,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_))->cmdline)
|
#define Process_getCommand(this_) (As_Process(this_)->getCommandStr ? As_Process(this_)->getCommandStr((const Process*)(this_)) : Process_getCommandStr((const Process*)(this_)))
|
||||||
#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) {
|
||||||
|
@ -369,4 +369,7 @@ int Process_pidCompare(const void* v1, const void* v2);
|
||||||
|
|
||||||
int Process_compareByKey_Base(const Process* p1, const Process* p2, ProcessField key);
|
int Process_compareByKey_Base(const Process* p1, const Process* p2, ProcessField key);
|
||||||
|
|
||||||
|
// Avoid direct calls, use Process_getCommand instead
|
||||||
|
const char *Process_getCommandStr(const Process *this);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -104,17 +104,6 @@ const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
|
||||||
[CWD] = { .name ="CWD", .title = "CWD ", .description = "The current working directory of the process", .flags = PROCESS_FLAG_LINUX_CWD, },
|
[CWD] = { .name ="CWD", .title = "CWD ", .description = "The current working directory of the process", .flags = PROCESS_FLAG_LINUX_CWD, },
|
||||||
};
|
};
|
||||||
|
|
||||||
/* This function returns the string displayed in Command column, so that sorting
|
|
||||||
* happens on what is displayed - whether comm, full path, basename, etc.. So
|
|
||||||
* this follows LinuxProcess_writeField(COMM) and LinuxProcess_writeCommand */
|
|
||||||
static const char* LinuxProcess_getCommandStr(const Process *this) {
|
|
||||||
if ((Process_isUserlandThread(this) && this->settings->showThreadNames) || !this->mergedCommand.str) {
|
|
||||||
return this->cmdline;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this->mergedCommand.str;
|
|
||||||
}
|
|
||||||
|
|
||||||
Process* LinuxProcess_new(const Settings* settings) {
|
Process* LinuxProcess_new(const Settings* settings) {
|
||||||
LinuxProcess* this = xCalloc(1, sizeof(LinuxProcess));
|
LinuxProcess* this = xCalloc(1, sizeof(LinuxProcess));
|
||||||
Object_setClass(this, Class(LinuxProcess));
|
Object_setClass(this, Class(LinuxProcess));
|
||||||
|
@ -835,6 +824,5 @@ const ProcessClass LinuxProcess_class = {
|
||||||
.compare = Process_compare
|
.compare = Process_compare
|
||||||
},
|
},
|
||||||
.writeField = LinuxProcess_writeField,
|
.writeField = LinuxProcess_writeField,
|
||||||
.getCommandStr = LinuxProcess_getCommandStr,
|
|
||||||
.compareByKey = LinuxProcess_compareByKey
|
.compareByKey = LinuxProcess_compareByKey
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue