Add wsl info output

Signed-off-by: Vitalii Koshura <lestat.de.lionkur@gmail.com>
This commit is contained in:
Vitalii Koshura 2018-04-29 13:28:50 +03:00
parent 87eb6d4459
commit e8f9ea7113
No known key found for this signature in database
GPG Key ID: CE0DB1726070A5A3
2 changed files with 15 additions and 10 deletions

View File

@ -252,6 +252,16 @@ void CLIENT_STATE::show_host_info() {
tz<0?"":"+", tz
);
#ifdef _WIN64
if (host_info.os_wsl_enabled) {
msg_printf(NULL, MSG_INFO,
"WSL detected: %s: %s", host_info.os_wsl_name, host_info.os_wsl_version
);
} else {
msg_printf(NULL, MSG_INFO, "No WSL found.");
}
#endif
if (strlen(host_info.virtualbox_version)) {
msg_printf(NULL, MSG_INFO,
"VirtualBox version: %s",

View File

@ -327,20 +327,19 @@ bool CreateWslProcess(const std::string& command, HANDLE& handle) {
si.cb = sizeof(STARTUPINFO);
si.hStdError = out_write;
si.hStdOutput = out_write;
si.hStdInput = NULL/*in_read*/;
si.hStdInput = NULL;
si.dwFlags |= STARTF_USESTDHANDLES;
const DWORD dwFlags = CREATE_NEW_CONSOLE/*CREATE_NO_WINDOW*/;
const DWORD dwFlags = CREATE_NO_WINDOW;
//std::stringstream ss;
//ss << "PATH=" << getenv("PATH") << '\0';
//LPCH env = GetEnvironmentStrings();
const std::string cmd = "bash -c \"" + command + "\"";
const bool res = (CreateProcess(NULL, (LPSTR)cmd.c_str(), NULL, NULL, TRUE, dwFlags, NULL, /*(LPVOID)env*/ NULL, &si, &pi) == TRUE);
const bool res = (CreateProcess(NULL, (LPSTR)cmd.c_str(), NULL, NULL, TRUE, dwFlags, NULL, NULL, &si, &pi) == TRUE);
if (res) {
//CloseHandle(pi.hProcess);
handle = pi.hProcess;
CloseHandle(pi.hThread);
}
@ -362,12 +361,6 @@ int close_handles_and_exit(const int return_code) {
return return_code;
}
//
//bool WriteToPipe(const std::string& str) {
// DWORD written;
//
// return WriteFile(in_write, str.c_str(), (DWORD)str.size(), &written, NULL) == TRUE;
//}
std::string ReadFromPipe(HANDLE handle) {
DWORD avail, read, exitcode;
@ -1089,9 +1082,11 @@ int get_os_information(
snprintf( os_version, os_version_size, "%s%s%s", szSKU, szServicePack, szVersion );
#ifdef _WIN64
if (osvi.dwMajorVersion >= 10) {
return get_wsl_information(os_wsl_enabled, os_wsl_name, os_wsl_name_size, os_wsl_version, os_wsl_version_size);
}
#endif
return 0;
}