When process not run with terminal, no column information will be
available through 'stty' command.
Set default width to 80 to account for this condition.
Signed-off-by: Leah Leshchinsky <lleshchi(a)redhat.com>
---
target branch: main
diff --git a/tuna-cmd.py b/tuna-cmd.py
index 630c8bc..e8d26d3 100755
--- a/tuna-cmd.py
+++ b/tuna-cmd.py
@@ -440,10 +440,12 @@ def ps_show(ps, affect_children, thread_list, cpu_list,
# Width of terminal in columns
- columns = None
if cgroups:
- _, columns = os.popen('stty size', 'r').read().split()
-
+ try:
+ with os.popen('stty size', 'r') as p:
+ _, columns = p.read().split()
+ except:
+ columns = 80
for pid in ps_list:
ps_show_thread(pid, affect_children, ps, has_ctxt_switch_info,
sock_inodes, sock_inode_re, cgroups, columns, compact)
--
2.38.1