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
pull from: git@gitlab.com:lleshchi/tuna.git
branch: main_format
commit: a410ba54a5cd995ea4b64b484403a21a972ea87b
diff --git a/tuna-cmd.py b/tuna-cmd.py
index 630c8bc..9862f86 100755
--- a/tuna-cmd.py
+++ b/tuna-cmd.py
@@ -440,10 +440,15 @@ 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()
+ columns = 80
+ if cgroups:
+ try:
+ # This can fail if not running on a term, default to 80 in that case
+ with os.popen('stty size', 'r') as p:
+ _, columns = p.read().split()
+ except:
+ pass
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
Show replies by date