Bug 229842 - top(1) interactive/batch mode shows empty output
Summary: top(1) interactive/batch mode shows empty output
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Many People
Assignee: Eitan Adler
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-07-17 19:49 UTC by Ali Abdallah
Modified: 2018-11-07 12:31 UTC (History)
3 users (show)

See Also:


Attachments
Fix screen_width in batch mode (676 bytes, patch)
2018-07-18 06:50 UTC, Ali Abdallah
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ali Abdallah 2018-07-17 19:49:12 UTC
top -n -o res for example shows empty output (I think it breaks after commit r336150)

The output looks like 
ast pid: 85237;  load averages:  0.26,  0.35,  0.38  up 0+06:27:10    21:45:37
95 processes:  2 running, 93 sleeping
CPU:  2.4% user,  0.0% nice,  0.9% system,  0.1% interrupt, 96.6% idle
Mem: 1G Active, 3G Inact, 412M Laundry, 5G Wired, 2G Buf, 5G Free
ARC: 1G Total, 54M MFU, 417M MRU, 1M Anon, 18M Header, 704M Other
     108M Compressed, 363M Uncompressed, 3.36:1 Ratio
Swap: 2G Total, 2G Free













--------------
From swap down, all empty.
Comment 1 Eitan Adler freebsd_committer freebsd_triage 2018-07-17 22:17:01 UTC
I plan on looking at this. Note that my development computer is currently dead so progress will be slow.
Comment 2 Ali Abdallah 2018-07-18 06:50:53 UTC
Created attachment 195231 [details]
Fix screen_width in batch mode

Please kindly apply the following patch. 

Actually this bug occurred in the past, from Changes top shipped with FreeBSD < 12

"Wed Dec 15 1993 - wnl (3.3beta2)
  ....
  Fixed bug with batch mode (screen_width wasn't getting set).
  ...."
Comment 3 Cy Schubert freebsd_committer freebsd_triage 2018-07-18 12:05:51 UTC
r336028 is the rev that changed this from MAX_COLS to 0. The patch is incorrect. screen_width must be dynamically set. If we are to make assumptions about dumb terminal screen width it would have to be within the if (!interactive) block.

Adding the committer of r336028 to the cc list.
Comment 4 Daichi GOTO 2018-07-26 14:03:23 UTC
Please check https://reviews.freebsd.org/D16455

I will commit it if there is no problem. Thank you.
Comment 5 commit-hook freebsd_committer freebsd_triage 2018-07-27 01:20:46 UTC
A commit references this bug:

Author: daichi
Date: Fri Jul 27 01:20:34 UTC 2018
New revision: 336753
URL: https://svnweb.freebsd.org/changeset/base/336753

Log:
  top(1): fixed the empty output problem in non-interactive mode (-n, -b) regressed in r336028

  PR:		229842
  Reported by:	Ali Abdallah <aliovx@gmail.com>
  Reviewed by:	eadler, cy
  Approved by:	gnn (mentor)
  Differential Revision:	https://reviews.freebsd.org/D16455

Changes:
  head/usr.bin/top/screen.c