[Bug 258409] top(1) outputs no processes when TERM is not set

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 10 Sep 2021 15:59:07 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=258409

            Bug ID: 258409
           Summary: top(1) outputs no processes when TERM is not set
           Product: Base System
           Version: 12.2-STABLE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: freqlabs@FreeBSD.org

We capture the output of top -SHIwz -d 2 in a debug script, but there are no
processes shown. The lines for the processes are all blank.

Upon investigation, this only occurs when TERM is not set in the environment.
This can be easily reproduced:

$ env TERM=dumb top -SHIwz -d 2 | cat

Processes are listed.

$ env -u TERM top -SHIwz -d 2 | cat

Blank lines are displayed where processes should be listed.

We are working around this issue with -n to force non-interactive mode, but it
would be good to fix top since screen_width = 0 doesn't seem like it would ever
be what someone actually wants.

I've reproduced this on 12 13 and CURRENT.

-- 
You are receiving this mail because:
You are the assignee for the bug.