Server::~Server()
{
- if (has_pid() and not kill())
+ if (has_pid() and not kill(_pid))
{
Error << "Unable to kill:" << *this;
}
pid_t current_pid;
while (--limit and (current_pid= get_pid()) != -1)
{
- if (kill())
+ if (kill(current_pid))
{
Log << "Killed existing server," << *this << " with pid:" << current_pid;
nap();
bool Server::start()
{
// If we find that we already have a pid then kill it.
- if (has_pid() and not kill())
+ if (has_pid() and not kill(_pid))
{
- Error << "Could not kill() existing server during start()";
+ Error << "Could not kill() existing server during start() pid:" << _pid;
return false;
}
assert(not has_pid());
}
// A failing get_pid() at this point is considered an error
- _pid= get_pid(false);
+ _pid= get_pid(true);
return has_pid();
}
return bool(getenv("LIBTEST_MANUAL_VALGRIND"));
}
-bool Server::kill()
+bool Server::kill(pid_t pid_arg)
{
- if (has_pid() and kill_pid(_pid)) // If we kill it, reset
+ if (check_pid(pid_arg) and kill_pid(pid_arg)) // If we kill it, reset
{
if (broken_pid_file() and not pid_file().empty())
{
{
for (std::vector<Server *>::iterator iter= servers.begin(); iter != servers.end(); iter++)
{
- if ((*iter)->has_pid() and not (*iter)->kill())
+ if ((*iter)->has_pid() and not (*iter)->kill((*iter)->pid()))
{
Error << "Unable to kill:" << *(*iter);
}
bool server_startup(server_startup_st& construct, const std::string& server_type, in_port_t try_port, int argc, const char *argv[])
{
- Logn();
+ Outn();
// Look to see if we are being provided ports to use
{
if (construct.is_debug())
{
- Log << "Pausing for startup, hit return when ready.";
+ Out << "Pausing for startup, hit return when ready.";
std::string gdb_command= server->base_command();
std::string options;
- Log << "run " << server->args(options);
+ Out << "run " << server->args(options);
getchar();
}
else if (not server->start())
}
else
{
- Log << "STARTING SERVER(pid:" << server->pid() << "): " << server->running();
+ Out << "STARTING SERVER(pid:" << server->pid() << "): " << server->running();
}
construct.push_server(server);
set_default_port(server->port());
}
- Logn();
+ Outn();
return true;
}
bool server_startup_st::start_socket_server(const std::string& server_type, const in_port_t try_port, int argc, const char *argv[])
{
- Logn();
+ (void)try_port;
+ Outn();
Server *server= NULL;
if (0)
if (is_debug())
{
- Log << "Pausing for startup, hit return when ready.";
+ Out << "Pausing for startup, hit return when ready.";
std::string gdb_command= server->base_command();
std::string options;
- Log << "run " << server->args(options);
+ Out << "run " << server->args(options);
getchar();
}
else if (not server->start())
}
else
{
- Log << "STARTING SERVER(pid:" << server->pid() << "): " << server->running();
+ Out << "STARTING SERVER(pid:" << server->pid() << "): " << server->running();
}
push_server(server);
set_default_socket(server->socket().c_str());
- Logn();
+ Outn();
return true;
}