Skip to content

Commit

Permalink
fix(crit): skip processes with no FDs
Browse files Browse the repository at this point in the history
Using `crit x fd` to list file descriptors now skips processes that have
no associated FDs.

Signed-off-by: Prajwal S N <[email protected]>
  • Loading branch information
snprajwal committed Aug 4, 2023
1 parent 5963a51 commit 82838bc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion crit/explore.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (c *crit) ExplorePs() (*PsTree, error) {
// Fd represents the file descriptors opened in a single process
type Fd struct {
PId uint32 `json:"pId"`
Files []*File `json:"files,omitempty"`
Files []*File `json:"files"`
}

// File represents a single opened file
Expand Down Expand Up @@ -145,6 +145,11 @@ func (c *crit) ExploreFds() ([]*Fd, error) {
Path: filePath,
})

// Omit if the process has no file descriptors
if len(fdEntry.Files) == 0 {
continue
}

fds = append(fds, &fdEntry)
}

Expand Down

0 comments on commit 82838bc

Please sign in to comment.