[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/work/icecream-non-linux-porting/icecream
From: Mirko Boehm <mirko () kde ! org>
Date: 2007-04-23 19:27:33
Message-ID: 1177356453.038441.9502.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 657305 by mirko:
- implement resource usage reporting for local jobs
M +5 -0 client/local.cpp
M +12 -7 services/ShellCommand.cpp
M +6 -0 services/ShellCommand.h
--- branches/work/icecream-non-linux-porting/icecream/client/local.cpp #657304:657305
@@ -201,5 +201,10 @@
cerr << command.output();
if ( ! command.error().empty() )
cerr << command.error();
+
+ if ( used != 0 ) {
+ ( *used ) = command.struct_ru();
+ }
+
return command.exitValue();
}
--- branches/work/icecream-non-linux-porting/icecream/services/ShellCommand.cpp #657304:657305
@@ -56,6 +56,7 @@
m_ru.reserve( RU_NumberOfValues );
for ( std::vector<int>::iterator it = m_ru.begin(); it !=m_ru.end(); ++it )
( *it ) = 0;
+
}
void ShellCommand::setCommand( const std::string& command, const std::list<std::string>& arguments )
@@ -276,7 +277,6 @@
static const int BufferSize = 4096;
char buffer[BufferSize];
bool childExited = false;
- struct rusage ru;
int status;
do {
fd_set rfds;
@@ -292,7 +292,7 @@
int max_fd = max( max( sock_out.fdNull(), sock_err.fdNull() ),
sock_in.fdOne() );
int ret = 0;
- if ( wait4(pid, &status, WNOHANG, &ru) == pid )
+ if ( wait4(pid, &status, WNOHANG, &m_struct_ru) == pid )
{
// cerr << "child process exited" << endl;
if ( WIFEXITED(status) ) {
@@ -371,13 +371,13 @@
= (endtv.tv_sec - starttv.tv_sec) * 1000 +
(long(endtv.tv_usec) - long(starttv.tv_usec)) / 1000;
m_ru[RU_User] // user msec
- = ru.ru_utime.tv_sec * 1000
- + ru.ru_utime.tv_usec / 1000;
+ = m_struct_ru.ru_utime.tv_sec * 1000
+ + m_struct_ru.ru_utime.tv_usec / 1000;
m_ru[RU_Sys] // sys msec
- = ru.ru_stime.tv_sec * 1000
- + ru.ru_stime.tv_usec / 1000;
+ = m_struct_ru.ru_stime.tv_sec * 1000
+ + m_struct_ru.ru_stime.tv_usec / 1000;
m_ru[RU_PFaults] // sys pfaults
- = ru.ru_majflt + ru.ru_nswap + ru.ru_minflt;
+ = m_struct_ru.ru_majflt + m_struct_ru.ru_nswap + m_struct_ru.ru_minflt;
}
void ShellCommand::handleStdOut( const char* const data, int count )
@@ -394,3 +394,8 @@
{
return m_ru;
}
+
+const struct rusage& ShellCommand::struct_ru() const
+{
+ return m_struct_ru;
+}
--- branches/work/icecream-non-linux-porting/icecream/services/ShellCommand.h #657304:657305
@@ -5,6 +5,10 @@
#include <list>
#include <vector>
+extern "C" {
+#include <sys/types.h>
+}
+
typedef std::list<std::string> Arguments;
class ShellCommand
@@ -30,6 +34,7 @@
void setInput( const std::string& input );
void execute();
+ const struct rusage& struct_ru() const; // to interface c functions
const std::string& output() const;
std::string output();
@@ -72,6 +77,7 @@
bool m_runAsRoot;
bool m_verbose;
std::vector<int> m_ru;
+ struct rusage m_struct_ru;
};
#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic