Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[disk][linux] add SELF_MOUNTINFO to use /proc/self
The changes to gopsutil for reading /proc/1/mountinfo affected applications running under restricted environments that disallows access to /proc/1/mountinfo. shirou#1159 was filed for android but other restricted environments are also affected (eg, snaps)). The fix for shirou#1159 addressed the application behavior to work under confinement for non-android as well. However, depending on the system, the attempt to read /proc/1/mountinfo could cause a sandbox denial in the logs which can be quite noisy if using gopsutil as part of a monitoring solution that polls often. This introduces the SELF_MOUNTINFO to force reading from /proc/self instead of first trying /proc/1. When unset or set to anything other than '1', retain the current behavior with fallback. This allows people to set SELF_MOUNTINFO=1 when gopsutil is running under these restricted environments.
- Loading branch information