Blame SOURCES/tuna-Fix-show_threads-cgroup-without-a-term.patch

31b149
From 613bc73f6ad821db682e9efc097c29af9cb40858 Mon Sep 17 00:00:00 2001
31b149
From: Leah Leshchinsky <lleshchi@redhat.com>
31b149
Date: Wed, 23 Nov 2022 14:14:36 -0500
31b149
Subject: [PATCH] tuna: Fix --show_threads --cgroup without a term
31b149
31b149
When tuna --show_threads --cgroups is run without a term,
31b149
provide a default column size of 80 to fix a traceback
31b149
that occurred when querying the terminal size.
31b149
31b149
Signed-off-by: Leah Leshchinsky <lleshchi@redhat.com>
31b149
- Edited the commit title
31b149
- Edited the description
31b149
Signed-off-by: John Kacur <jkacur@redhat.com>
31b149
31b149
diff --git a/tuna-cmd.py b/tuna-cmd.py
31b149
index 54dc567..f5dafa7 100755
31b149
--- a/tuna-cmd.py
31b149
+++ b/tuna-cmd.py
31b149
@@ -31,6 +31,7 @@ import procfs
31b149
 from tuna import tuna, sysfs
31b149
 import logging
31b149
 import time
31b149
+import shutil
31b149
 
31b149
 def get_loglevel(level):
31b149
     if level.isdigit() and int(level) in range(0,5):
31b149
@@ -353,9 +354,10 @@ def ps_show(ps, affect_children, thread_list, cpu_list,
31b149
     ps_list.sort()
31b149
 
31b149
     # Width of terminal in columns
31b149
-    columns = None
31b149
+    columns = 80
31b149
     if cgroups:
31b149
-        _, columns = os.popen('stty size', 'r').read().split()
31b149
+        if os.isatty(sys.stdout.fileno()):
31b149
+            columns = shutil.get_terminal_size().columns
31b149
 
31b149
     for pid in ps_list:
31b149
         ps_show_thread(pid, affect_children, ps, has_ctxt_switch_info,
31b149
-- 
31b149
2.38.1
31b149