From 720ae25981607a50cbcb127c47d8663c4403785b Mon Sep 17 00:00:00 2001 From: wens Date: Mon, 17 Oct 2005 16:19:00 +0000 Subject: Add data and stack size display for linux git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3225 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/cal.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'mbbsd/cal.c') diff --git a/mbbsd/cal.c b/mbbsd/cal.c index 30e02166..4cab90f9 100644 --- a/mbbsd/cal.c +++ b/mbbsd/cal.c @@ -460,14 +460,34 @@ p_sysinfo(void) compile_time, ctime4(&start_time)); if (HasUserPerm(PERM_SYSOP)) { struct rusage ru; +#ifdef __linux__ + int vmdata=0, vmstk=0; + { + FILE * fp; + char buf[128]; + if ((fp = fopen("/proc/self/status", "r"))) { + while (fgets(buf, 128, fp) && vmdata==0 && vmstk==0) { + sscanf(buf, "VmData: %d", &vmdata); + sscanf(buf, "VmStk: %d", &vmstk); + } + fclose(fp); + } + } +#endif getrusage(RUSAGE_SELF, &ru); prints("記憶體用量: " #ifdef IA32 "sbrk: %d KB, " +#endif +#ifdef __linux__ + "VmData: %d KB, VmStk: %d KB, " #endif "idrss: %d KB, isrss: %d KB\n", #ifdef IA32 ((int)sbrk(0) - 0x8048000) / 1024, +#endif +#ifdef __linux__ + vmdata, vmstk, #endif (int)ru.ru_idrss, (int)ru.ru_isrss); prints("CPU 用量: %ld.%06ldu %ld.%06lds", -- cgit v1.2.3