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: getopt
pull from: git@gitlab.com:lleshchi/tuna.git
branch: getopt_format
commit: 4a27664a3e2584e76b336084951933559ab58c34
diff --git a/tuna-cmd.py b/tuna-cmd.py
index 54dc567..42aa326 100755
--- a/tuna-cmd.py
+++ b/tuna-cmd.py
@@ -353,10 +353,15 @@ def ps_show(ps, affect_children, thread_list, cpu_list,
ps_list.sort()
# 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