Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 177464 Details for
Bug 132894
sys-process/procps-3.2.5-r1 - top crashes with very small terminal
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
procps-3.2.7-top-resize.patch
procps-3.2.7-top-resize.patch (text/plain), 3.27 KB, created by
Pacho Ramos
on 2009-01-05 12:34:41 UTC
(
hide
)
Description:
procps-3.2.7-top-resize.patch
Filename:
MIME Type:
Creator:
Pacho Ramos
Created:
2009-01-05 12:34:41 UTC
Size:
3.27 KB
patch
obsolete
> >#! /bin/sh /usr/share/dpatch/dpatch-run >## 20top_resize_terminal.dpatch by <hesso@pool.math.tu-berlin.de> >## >## DP: Prevent top from segfaulting when the display is shrinked to only >## DP: a few (read: 3 or less) lines. > >@DPATCH@ >--- procps-3.2.7.orig/top.c 2006-06-25 08:41:48.000000000 +0200 >+++ procps-3.2.7/top.c 2007-08-06 03:27:28.000000000 +0200 >@@ -140,7 +140,7 @@ > are exploited in a macro and represent 90% of our optimization. > The Stdout_buf is transparent to our code and regardless of whose > buffer is used, stdout is flushed at frame end or if interactive. */ >-static char *Pseudo_scrn; >+static PSEUDO_SCREEN_t Pseudo_scrn; > static int Pseudo_row, Pseudo_cols, Pseudo_size; > #ifndef STDOUT_IOLBF > // less than stdout's normal buffer but with luck mostly '\n' anyway >@@ -2415,7 +2415,10 @@ > Pseudo_cols = Screen_cols + CLRBUFSIZ + 1; > if (Batch) Pseudo_size = ROWBUFSIZ + 1; > else Pseudo_size = Pseudo_cols * Screen_rows; >- Pseudo_scrn = alloc_r(Pseudo_scrn, Pseudo_size); >+ if( Pseudo_scrn.buf == NULL || Pseudo_size > Pseudo_scrn.mem_size ) { >+ Pseudo_scrn.buf = alloc_r(Pseudo_scrn.buf, Pseudo_size); >+ Pseudo_scrn.mem_size = Pseudo_size; >+ } > > // force rebuild of column headers AND libproc/readproc requirements > Frames_libflags = 0; >@@ -3289,7 +3292,7 @@ > // reframewins(), who also builds each window's column headers > if (!Frames_libflags) { > reframewins(); >- memset(Pseudo_scrn, '\0', Pseudo_size); >+ memset(Pseudo_scrn.buf, '\0', Pseudo_size); > } > Pseudo_row = Msg_row = scrlins = 0; > ppt = summary_show(); >--- procps-3.2.7.orig/top.h 2006-06-25 08:41:48.000000000 +0200 >+++ procps-3.2.7/top.h 2007-08-06 03:27:28.000000000 +0200 >@@ -135,7 +135,7 @@ > int _len = 1 + snprintf(_str, sizeof(_str), fmt, ## arg); \ > putp ( Batch ? _str : \ > ({ \ >- char *restrict const _pse = &Pseudo_scrn[Pseudo_row++ * Pseudo_cols]; \ >+ char *restrict const _pse = &Pseudo_scrn.buf[Pseudo_row++ * Pseudo_cols]; \ > memcmp(_pse, _str, _len) ? memcpy(_pse, _str, _len) : "\n"; \ > }) \ > ); \ >@@ -149,7 +149,11 @@ > int _len = 1 + snprintf(_str, sizeof(_str), fmt, ## arg); \ > if (Batch) _ptr = _str; \ > else { \ >- _ptr = &Pseudo_scrn[Pseudo_row++ * Pseudo_cols]; \ >+ if (Pseudo_row * Pseudo_cols + _len > Pseudo_size) { \ >+ Pseudo_scrn.buf = realloc(Pseudo_scrn.buf, Pseudo_row * Pseudo_cols + _len); \ >+ Pseudo_scrn.mem_size = Pseudo_size = Pseudo_row * Pseudo_cols + _len; \ >+ } \ >+ _ptr = &Pseudo_scrn.buf[Pseudo_row++ * Pseudo_cols]; \ > if (memcmp(_ptr, _str, _len)) { \ > memcpy(_ptr, _str, _len); \ > } else { \ >@@ -237,6 +241,11 @@ > RCW_t win [4]; // a 'WIN_t.rc' for each of the 4 windows > } RCF_t; > >+typedef struct PSEUDO_SCREEN_t { >+ char *buf; >+ int mem_size; >+} PSEUDO_SCREEN_t; >+ > // The scaling 'type' used with scale_num() -- this is how > // the passed number is interpreted should scaling be necessary > enum scale_num { >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 132894
: 177464