diff options
author | Fabian Groffen <grobian@gentoo.org> | 2015-04-17 09:15:44 +0200 |
---|---|---|
committer | Fabian Groffen <grobian@gentoo.org> | 2015-04-17 09:15:44 +0200 |
commit | df3d5271b9153c6510c6178194bb33cbd1a7b732 (patch) | |
tree | eb57f308be6622beb0e74cf76a7d4dacb9bad597 /psutil/_pssunos.py | |
parent | ef7f9656a1d7e5a4d267f4f2e2fd674965b65a9d (diff) | |
download | psutil-df3d5271b9153c6510c6178194bb33cbd1a7b732.tar.gz |
swap: fix finding the 'swap' utility on SunOS
This is a bit of a kludge, but allows to find the swap utility when
invoced by normal users which shouldn't have the sbin paths in PATH by
default. One can argue the paths should be appended instead of
prepended, but I doubt whether one wants to use another swap utility,
since the code relies on its output format.
Diffstat (limited to 'psutil/_pssunos.py')
-rw-r--r-- | psutil/_pssunos.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/psutil/_pssunos.py b/psutil/_pssunos.py index bb47fd29..b438697d 100644 --- a/psutil/_pssunos.py +++ b/psutil/_pssunos.py @@ -96,7 +96,8 @@ def swap_memory(): # usr/src/cmd/swap/swap.c # ...nevertheless I can't manage to obtain the same numbers as 'swap' # cmdline utility, so let's parse its output (sigh!) - p = subprocess.Popen(['swap', '-l', '-k'], stdout=subprocess.PIPE) + p = subprocess.Popen(['/usr/bin/env', 'PATH=/usr/sbin:/sbin:%s' % + os.environ['PATH'], 'swap', '-l', '-k'], stdout=subprocess.PIPE) stdout, stderr = p.communicate() if PY3: stdout = stdout.decode(sys.stdout.encoding) |