crazy Debian GNU/kFreeBSD guy wanted this
This commit is contained in:
12
ps/common.h
12
ps/common.h
@@ -13,8 +13,8 @@
|
||||
#define PROCPS_PS_H
|
||||
|
||||
#include "../proc/procps.h"
|
||||
#include "../proc/escape.h"
|
||||
#include "../proc/readproc.h"
|
||||
#include <asm/page.h> /* looks safe for glibc, we need PAGE_SIZE */
|
||||
|
||||
#if 0
|
||||
#define trace(args...) printf(## args)
|
||||
@@ -60,15 +60,17 @@
|
||||
* Try not to overflow the output buffer:
|
||||
* 32 pages for env+cmd
|
||||
* 64 kB pages on IA-64
|
||||
* 4 chars for "\377"
|
||||
* 4 chars for "\377", or 1 when mangling to '?' (ESC_STRETCH)
|
||||
* plus some slack for other stuff
|
||||
* That is about 8.5 MB on IA-64, or 0.6 MB on i386
|
||||
*
|
||||
* Sadly, current kernels only supply one page of env/command data.
|
||||
* The buffer is now protected with a guard page, and via other means
|
||||
* to avoid hitting the guard page.
|
||||
*/
|
||||
|
||||
/* maximum escape expansion is 4, for \377 */
|
||||
#define ESC_STRETCH 4
|
||||
/* output buffer size */
|
||||
#define OUTBUF_SIZE (32*PAGE_SIZE*ESC_STRETCH + 8*PAGE_SIZE)
|
||||
#define OUTBUF_SIZE (2 * 64*1024 * ESC_STRETCH)
|
||||
|
||||
/******************* PS DEFINE *******************/
|
||||
|
||||
|
||||
@@ -479,10 +479,10 @@ void self_info(void){
|
||||
|
||||
fprintf(stderr,
|
||||
"personality=0x%08x (from \"%s\")\n"
|
||||
"EUID=%d TTY=%d,%d Hertz=%Ld PAGE_SIZE=%d page_size=%d\n",
|
||||
"EUID=%d TTY=%d,%d Hertz=%Ld page_size=%d\n",
|
||||
personality, saved_personality_text,
|
||||
cached_euid, (int)major(cached_tty), (int)minor(cached_tty), Hertz,
|
||||
(int)(PAGE_SIZE), (int)(page_size)
|
||||
(int)(page_size)
|
||||
);
|
||||
|
||||
fprintf(stderr,
|
||||
|
||||
@@ -696,7 +696,7 @@ static int pr_tty4(char *restrict const outbuf, const proc_t *restrict const pp)
|
||||
/* Unix98: format is unspecified, but must match that used by who(1). */
|
||||
static int pr_tty8(char *restrict const outbuf, const proc_t *restrict const pp){
|
||||
/* snprintf(outbuf, COLWID, "%02x:%02x", pp->tty>>8, pp->tty&0xff); */
|
||||
return dev_to_tty(outbuf, PAGE_SIZE-1, pp->tty, pp->XXXID, ABBREV_DEV);
|
||||
return dev_to_tty(outbuf, COLWID, pp->tty, pp->XXXID, ABBREV_DEV);
|
||||
}
|
||||
|
||||
#if 0
|
||||
@@ -804,7 +804,7 @@ static int pr_alarm(char *restrict const outbuf, const proc_t *restrict const pp
|
||||
|
||||
/* HP-UX puts this in pages and uses "vsz" for kB */
|
||||
static int pr_sz(char *restrict const outbuf, const proc_t *restrict const pp){
|
||||
return snprintf(outbuf, COLWID, "%lu", (pp->vm_size)/(PAGE_SIZE/1024));
|
||||
return snprintf(outbuf, COLWID, "%lu", (pp->vm_size)/(page_size/1024));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user