Skip to content

Commit

Permalink
added a comment
Browse files Browse the repository at this point in the history
  • Loading branch information
iritb committed Jan 8, 2025
1 parent 3a4e3cc commit fec47ad
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions ProcessTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,21 @@ std::shared_ptr<ProcessTreeItem> ProcessTree::AddProcess(enum ProcessTreeSource
ApplyFlags(process);
_processes[pid] = process;
}

// Call ReadProcEntry to ensure container ID is set if it's still empty

// The purpose of extracting the container ID from cgroup is to accurately identify
// the container in which a process is running. This is particularly important for
// monitoring and logging purposes in containerized environments, where applications
// are packaged and run in containers. By testing the extraction logic with various
// cgroup formats, we aim to ensure that the container ID is correctly identified in
// all scenarios.
// This method complements the existing logic that extracts the container ID from the
// command line arguments by providing an additional, more reliable source of information.
// This is especially relevant when the container ID is not found through the existing
// logic, which can happen when there is no parent process or when the parent process
// does not have the container ID set. This situation can occur in various scenarios,
// such as when a process is the root process of a container or when the process is
// started by a web service or another system service that does not pass the container
// ID through the command line arguments.
if (process->_containerid.empty()) {
auto p_temp = ReadProcEntry(pid);
if (p_temp) {
Expand Down

0 comments on commit fec47ad

Please sign in to comment.