#include <mysqlDaemon.hpp>

Public Member Functions | |
| MySQLDaemon (const std::string &_datadir, const std::string &_socket) throw (Error) | |
| virtual | ~MySQLDaemon (void) |
| bool | running (void) |
| const std::string | getLog (void) |
Static Public Member Functions | |
| static std::string | create (const std::string &_datadir, const std::string &_socket) throw (Error) |
Protected Member Functions | |
| void | readPending (void) |
Protected Attributes | |
| int | pipes [2] |
| pid_t | pid |
| std::ostringstream | log |
Definition at line 27 of file mysqlDaemon.hpp.
| MySQLDaemon::MySQLDaemon | ( | const std::string & | _datadir, | |
| const std::string & | _socket | |||
| ) | throw (Error) |
Constructor.
| _datadir | Directory of database server. | |
| _socket | The database-server should use this file-socket. |
| MySQLDaemon::~MySQLDaemon | ( | void | ) | [virtual] |
Definition at line 67 of file mysqlDaemon.cpp.
References pid.
00068 { 00069 kill( pid, SIGQUIT );// SIGTERM required on older systems. 00070 int status; 00071 waitpid( pid, &status, 0 ); 00072 }
| bool MySQLDaemon::running | ( | void | ) |
Definition at line 74 of file mysqlDaemon.cpp.
References pid.
00075 { 00076 int status; 00077 return waitpid( pid, &status, WNOHANG ) == 0; 00078 }
| const string MySQLDaemon::getLog | ( | void | ) |
Definition at line 80 of file mysqlDaemon.cpp.
References log, and readPending().
00081 { 00082 readPending(); 00083 return log.str(); 00084 }
| static std::string MySQLDaemon::create | ( | const std::string & | _datadir, | |
| const std::string & | _socket | |||
| ) | throw (Error) [static] |
Create database. This method calls 'mysql_install_db' to create the database directories.
| _datadir | Directory for database. | |
| _socket | Temporary socket required by some distributions. |
| void MySQLDaemon::readPending | ( | void | ) | [protected] |
Definition at line 106 of file mysqlDaemon.cpp.
Referenced by getLog().
00107 { 00108 int filedes = pipes[0]; 00109 00110 fd_set set; 00111 struct timeval timeout; 00112 00113 FD_ZERO(&set); 00114 FD_SET (filedes, &set); 00115 00116 timeout.tv_sec = 0; 00117 timeout.tv_usec = 0; 00118 00119 while( true ) { 00120 00121 int count; 00122 ioctl( filedes, FIONREAD, &count ); 00123 if ( count == 0 ) 00124 break; 00125 shared_array< char > buffer( new char[ count + 1 ] ); 00126 read( filedes, buffer.get(), count ); 00127 buffer[ count ] = 0; 00128 log << buffer.get(); 00129 00130 }; 00131 }
int MySQLDaemon::pipes[2] [protected] |
pid_t MySQLDaemon::pid [protected] |
std::ostringstream MySQLDaemon::log [protected] |