| 117 | } |
| 118 | |
| 119 | bool SFTPTestServer::stop() { |
| 120 | #ifdef WIN32 |
| 121 | throw std::runtime_error("Not implemented"); |
| 122 | #else |
| 123 | if (server_pid_ != -1) { |
| 124 | if (::kill(server_pid_, SIGTERM) != 0) { |
| 125 | logger_->log_error("Failed to kill child process, error: %s", strerror(errno)); |
| 126 | return false; |
| 127 | } |
| 128 | int wstatus; |
| 129 | if (::waitpid(server_pid_, &wstatus, 0) == -1) { |
| 130 | logger_->log_error("Failed to waitpid for child process, error: %s", strerror(errno)); |
| 131 | return false; |
| 132 | } |
| 133 | } |
| 134 | if (!port_file_path_.empty()) { |
| 135 | logger_->log_debug("Deleting port file %s", port_file_path_.c_str()); |
| 136 | ::unlink(port_file_path_.c_str()); |
| 137 | } |
| 138 | #endif |
| 139 | server_pid_ = -1; |
| 140 | started_ = false; |
| 141 | port_file_path_ = ""; |
| 142 | return true; |
| 143 | } |
| 144 | |
| 145 | uint16_t SFTPTestServer::getPort() { |
| 146 | return port_; |
no test coverage detected