Skip to content

Commit

Permalink
Linux: add process column whether it is marked a container process
Browse files Browse the repository at this point in the history
Might be useful for some users and for debugging the
hideRunningInContainer detection.
  • Loading branch information
cgzones committed Jan 20, 2024
1 parent 1831879 commit d8948e7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
16 changes: 16 additions & 0 deletions linux/LinuxProcess.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
[CWD] = { .name = "CWD", .title = "CWD ", .description = "The current working directory of the process", .flags = PROCESS_FLAG_CWD, },
[AUTOGROUP_ID] = { .name = "AUTOGROUP_ID", .title = "AGRP", .description = "The autogroup identifier of the process", .flags = PROCESS_FLAG_LINUX_AUTOGROUP, },
[AUTOGROUP_NICE] = { .name = "AUTOGROUP_NICE", .title = " ANI", .description = "Nice value (the higher the value, the more other processes take priority) associated with the process autogroup", .flags = PROCESS_FLAG_LINUX_AUTOGROUP, },
[ISCONTAINER] = { .name = "ISCONTAINER", .title = "CONT ", .description = "Whether the process is running inside a child container", .flags = PROCESS_FLAG_LINUX_CONTAINER, },
#ifdef SCHEDULER_SUPPORT
[SCHEDULERPOLICY] = { .name = "SCHEDULERPOLICY", .title = "SCHED ", .description = "Current scheduling policy of the process", .flags = PROCESS_FLAG_SCHEDPOL, },
#endif
Expand Down Expand Up @@ -332,6 +333,19 @@ static void LinuxProcess_rowWriteField(const Row* super, RichString* str, Proces
xSnprintf(buffer, n, "N/A ");
}
break;
case ISCONTAINER:
switch (this->isRunningInContainer) {
case TRI_ON:
xSnprintf(buffer, n, "YES ");
break;
case TRI_OFF:
xSnprintf(buffer, n, "NO ");
break;
default:
attr = CRT_colors[PROCESS_SHADOW];
xSnprintf(buffer, n, "N/A ");
}
break;
default:
Process_writeField(this, str, field);
return;
Expand Down Expand Up @@ -425,6 +439,8 @@ static int LinuxProcess_compareByKey(const Process* v1, const Process* v2, Proce
return SPACESHIP_NUMBER(p1->autogroup_id, p2->autogroup_id);
case AUTOGROUP_NICE:
return SPACESHIP_NUMBER(p1->autogroup_nice, p2->autogroup_nice);
case ISCONTAINER:
return SPACESHIP_NUMBER(v1->isRunningInContainer, v2->isRunningInContainer);
default:
return Process_compareByKey_Base(v1, v2, key);
}
Expand Down
1 change: 1 addition & 0 deletions linux/LinuxProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ in the source distribution for its full text.
#define PROCESS_FLAG_LINUX_LRS_FIX 0x00010000
#define PROCESS_FLAG_LINUX_DELAYACCT 0x00040000
#define PROCESS_FLAG_LINUX_AUTOGROUP 0x00080000
#define PROCESS_FLAG_LINUX_CONTAINER 0x00100000

typedef struct LinuxProcess_ {
Process super;
Expand Down
2 changes: 1 addition & 1 deletion linux/LinuxProcessTable.c
Original file line number Diff line number Diff line change
Expand Up @@ -1668,7 +1668,7 @@ static bool LinuxProcessTable_recurseProcTree(LinuxProcessTable* this, openat_ar
}

if (ss->flags & PROCESS_FLAG_LINUX_CTXT
|| (hideRunningInContainer && proc->isRunningInContainer == TRI_INITIAL)
|| ((hideRunningInContainer || ss->flags & PROCESS_FLAG_LINUX_CONTAINER) && proc->isRunningInContainer == TRI_INITIAL)
#ifdef HAVE_VSERVER
|| ss->flags & PROCESS_FLAG_LINUX_VSERVER
#endif
Expand Down
1 change: 1 addition & 0 deletions linux/ProcessField.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ in the source distribution for its full text.
CCGROUP = 129, \
CONTAINER = 130, \
M_PRIV = 131, \
ISCONTAINER = 132, \
// End of list


Expand Down

0 comments on commit d8948e7

Please sign in to comment.