Confdump Agent
1.4.0
|
00001 /* 00002 * Confdump-Agent - Dump static and runtime system configuration 00003 * Copyright (C) 2009-2012 Straton IT, SAS 00004 * 00005 * This program is free software: you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License version 3 as 00007 * published by the Free Software Foundation. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 00018 #include <sstream> 00019 00020 #include "boost/iostreams/copy.hpp" 00021 00022 #include "Confdump/System/Linux/Process.hpp" 00023 #include "Confdump/System/LinuxDumper.hpp" 00024 #include "Confdump/System/Linux/ConfigurationFile.hpp" 00025 00026 using boost::shared_ptr; 00027 using std::streambuf; 00028 00029 namespace Confdump 00030 { 00031 00032 namespace System 00033 { 00034 00035 namespace Linux 00036 { 00037 00038 Process::Process( boost::shared_ptr<LinuxDumper> driver, uint pid ) 00039 : pid_( pid ) 00040 { 00041 QByteArray file = driver->systemContext().slurpConfigurationFile( QString( "/proc/%1/cmdline" ).arg( pid ), "CD_Process" ); 00042 QString raw_cmdline(QString::fromLocal8Bit(file)); 00043 if ( raw_cmdline.size() == 0 ) 00044 { 00045 raw_cmdline.resize(1); 00046 raw_cmdline += '\0' ; 00047 } 00048 arguments_ = raw_cmdline.split( QChar( '\0' ) ); 00049 } 00050 00051 Process::~Process() 00052 { 00053 } 00054 00055 QString Process::commandLine() const 00056 { 00057 return arguments_.join( " " ); 00058 } 00059 00060 } 00061 } 00062 }