If one does something like
top -b -d 2 | grep state
(to get the line showing % idle), and resizes the window while it runs,
it tends to coredump, probably in the strcpy() trying to save the escape
sequence to go to bottom-right given the new window size.
This happens on 3.8beta1 (Solaris 11), but also on versions at least
back to 3.5beta9 (Solaris 9). In principle, it could happen on other OSs too,
but that's what I have handy that comes with this implementation of "top".
(I've also posted most of this on comp,unix.solaris, and mentioned there that I
filed a ticket here.)
Some simple changes can be made to stop it from attempting to handle
window resize if stdout is not a tty. The test could perhaps be done
once, and a variable set, to make it more efficient than what I did, but
this is the basic answer to the problem. The following is for 3.8beta1,
but the principle probably is similar in older versions, even if the details
vary.
$ diff top.c.orig top.c
230c230,231
< sigaddset(&signalset, SIGWINCH);
if (isatty(1)) sigaddset(&signalset, SIGWINCH);241c242,243
< sighold(SIGWINCH);
if (isatty(1)) sighold(SIGWINCH);267c269,270
< (void) set_signal(SIGWINCH, sig_winch);
if (isatty(1)) (void) set_signal(SIGWINCH, sig_winch);284c287,288
< sigrelse(SIGWINCH);
if (isatty(1)) sigrelse(SIGWINCH);
Richard, in OpenIndiana (an illumos distribution) we ship this patch https://sourceforge.net/p/unixtop/patches/22/ and it fixed it for us.