Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Handle lsof exit status 1 indicating no use of mount points #27209

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions go/lsof/lsof.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,14 @@ func (e ExecError) Error() string {

// MountPoint returns processes using the mountpoint "lsof /dir"
func MountPoint(dir string) ([]Process, error) {
// TODO: Fix lsof to not return error on exit status 1 since it isn't
// really any error, only an indication that there was no use of the
// mount.
return run([]string{"-F", "pcuftn", dir})
processes, err := run([]string{"-F", "pcuftn", dir})
if err != nil {
if strings.Contains(err.Error(), "exit status 1") {
return processes, nil
}
return nil, err
}
return processes, nil
}

func fileTypeFromString(s string) FileType {
Expand Down