diff --git a/doc/changelog.rst b/doc/changelog.rst index cb95707f..44d164f1 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -6,6 +6,9 @@ Version 2.12.0 (unreleased) * Bugfix: Remove the Linux version check, which was broken and no longer needed. Patch by Michael Greenberg. +* Bugfix: ``pyperf system`` no longer prints systemctl's "Unit + irqbalance.service could not be found." message when irqbalance isn't + installed. Patch by Michael Greenberg. Version 2.11.0 (2026-11-08) --------------------------- diff --git a/pyperf/_system.py b/pyperf/_system.py index 13dd7703..993f0d11 100644 --- a/pyperf/_system.py +++ b/pyperf/_system.py @@ -58,16 +58,17 @@ def get_output(cmd): try: proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, + stderr=subprocess.PIPE, universal_newlines=True) except OSError as exc: if exc.errno == errno.ENOENT: - return (127, '') + return (127, '', '') else: raise - stdout = popen_communicate(proc)[0] + stdout, stderr = popen_communicate(proc) exitcode = proc.returncode - return (exitcode, stdout) + return (exitcode, stdout, stderr) def use_intel_pstate(): @@ -650,7 +651,13 @@ def __init__(self, system): def read_irqbalance_systemctl(self): cmd = ('systemctl', 'status', 'irqbalance') - exitcode, stdout = get_output(cmd) + exitcode, stdout, stderr = get_output(cmd) + if exitcode == 4 and not stdout: + # systemctl exits with status 4 and prints its error on stderr + # when there is no irqbalance unit. The service isn't + # installed, so there is nothing to show or change. + self.systemctl = True + return if not stdout: # systemctl is not installed? ignore errors self.systemctl = False @@ -682,7 +689,7 @@ def read_irqbalance_systemctl(self): def read_irqbalance_service(self): cmd = ('service', 'irqbalance', 'status') - exitcode, stdout = get_output(cmd) + exitcode, stdout, stderr = get_output(cmd) if not stdout: # failed to the the status: ignore return