Skip to content

Commit

Permalink
fix: close /proc/1/mountinfo (#4802)
Browse files Browse the repository at this point in the history
Signed-off-by: guoguangwu <[email protected]>
  • Loading branch information
testwill authored May 14, 2024
1 parent fc2d91d commit 0897335
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cmd/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,9 +455,15 @@ func insideContainer() bool {
return true
}
mountinfo, err := os.Open("/proc/1/mountinfo")
if os.IsNotExist(err) {
return false
if err != nil {
if os.IsNotExist(err) {
return false
} else {
logger.Warnf("Open /proc/1/mountinfo: %s", err)
return false
}
}
defer mountinfo.Close()
scanner := bufio.NewScanner(mountinfo)
for scanner.Scan() {
line := scanner.Text()
Expand Down

0 comments on commit 0897335

Please sign in to comment.