From e188badaf29a1a02307f93864eed6737096bd9a1 Mon Sep 17 00:00:00 2001 From: Adam Moss Date: Tue, 3 Feb 2009 17:56:26 +0000 Subject: QAR-1177 maint-viewer-12 + uploadfees-viewer combo mergeme svn merge -r108355:109316 svn+ssh://svn.lindenlab.com/svn/linden/branches/moss/maint-viewer-12-uploadfees-qa108314 Whew. --- indra/llcommon/llmemory.cpp | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'indra/llcommon/llmemory.cpp') diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp index 29f916bc46..a6de3d2d69 100644 --- a/indra/llcommon/llmemory.cpp +++ b/indra/llcommon/llmemory.cpp @@ -39,7 +39,7 @@ # include # include # include -#elif defined(LL_LINUX) +#elif LL_LINUX || LL_SOLARIS # include #endif @@ -389,6 +389,34 @@ bail: return rss; } +#elif LL_SOLARIS +#include +#include +#include +#define _STRUCTURED_PROC 1 +#include + +U64 getCurrentRSS() +{ + char path [LL_MAX_PATH]; /* Flawfinder: ignore */ + + sprintf(path, "/proc/%d/psinfo", (int)getpid()); + int proc_fd = -1; + if((proc_fd = open(path, O_RDONLY)) == -1){ + llwarns << "LLmemory::getCurrentRSS() unable to open " << path << ". Returning 0 RSS!" << llendl; + return 0; + } + psinfo_t proc_psinfo; + if(read(proc_fd, &proc_psinfo, sizeof(psinfo_t)) != sizeof(psinfo_t)){ + llwarns << "LLmemory::getCurrentRSS() Unable to read from " << path << ". Returning 0 RSS!" << llendl; + close(proc_fd); + return 0; + } + + close(proc_fd); + + return((U64)proc_psinfo.pr_rssize * 1024); +} #else U64 getCurrentRSS() -- cgit v1.2.3