Skip to content

Commit

Permalink
Merge branch 'mac-azure' of github.com:stream-labs/crash-handler into…
Browse files Browse the repository at this point in the history
… mac-azure
  • Loading branch information
EddyGharbi committed Mar 26, 2020
2 parents d7b0b40 + 6c18131 commit 05f3c23
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 44 deletions.
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:

- job: 'MacOSX'
pool:
vmImage: 'macos-10.15'
vmImage: 'macos-10.14'
workspace:
clean: all

Expand Down
36 changes: 18 additions & 18 deletions crash-handler-process/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
#include <chrono>
#include <sstream>
#include <iomanip>
#include <filesystem>
// #include <filesystem>

bool log_output_disabled = false;

namespace fs = std::filesystem;
// namespace fs = std::filesystem;
std::ofstream log_output_file;

const std::string getTimeStamp()
Expand All @@ -45,27 +45,27 @@ const std::string getTimeStamp()

void logging_start(std::wstring log_path)
{
if( log_path.size() == 0 )
log_output_disabled = true;
// if( log_path.size() == 0 )
// log_output_disabled = true;

if( !log_output_disabled )
{
try {
fs::path log_file = log_path;
fs::path log_file_old = log_file;
log_file_old.replace_extension("log.old");
// if( !log_output_disabled )
// {
// try {
// fs::path log_file = log_path;
// fs::path log_file_old = log_file;
// log_file_old.replace_extension("log.old");

fs::remove_all(log_file_old);
fs::rename(log_file, log_file_old);
} catch (...) {
// fs::remove_all(log_file_old);
// fs::rename(log_file, log_file_old);
// } catch (...) {

}
log_output_file.open( log_path, std::ios_base::out | std::ios_base::app);
}
// }
// log_output_file.open( log_path, std::ios_base::out | std::ios_base::app);
// }
}

void logging_end()
{
if( !log_output_disabled )
log_output_file.close();
// if( !log_output_disabled )
// log_output_file.close();
}
50 changes: 25 additions & 25 deletions crash-handler-process/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,38 +144,38 @@ std::string get_process_name(ProcessInfo pi)
#endif
return "";
}
std::fstream open_file(std::string& file_path, std::fstream::openmode mode)
{
return std::fstream(from_utf8_to_utf16_wide(file_path.c_str()), mode);
}
// std::fstream open_file(std::string& file_path, std::fstream::openmode mode)
// {
// return std::fstream(from_utf8_to_utf16_wide(file_path.c_str()), mode);
// }
bool kill(ProcessInfo pinfo, uint32_t code)
{
#ifdef WIN32
return TerminateProcess(reinterpret_cast<HANDLE>(pinfo.handle), code);
#endif
return true;
}
static void check_pid_file(std::string& pid_path)
{
std::fstream::openmode mode = std::fstream::in | std::fstream::binary;
std::fstream pid_file(open_file(pid_path, mode));
union
{
uint64_t pid;
char pid_char[sizeof(uint64_t)];
};
if (!pid_file)
return;
pid_file.read(&pid_char[0], 8);
ProcessInfo pi = open_process(pid);
if (pi.handle == 0)
return;
std::string name = get_process_name(pi);
if (name.find("crash-handler-process.exe") != std::string::npos) {
kill(pi, -1);
}
close_process(pi);
}
// static void check_pid_file(std::string& pid_path)
// {
// std::fstream::openmode mode = std::fstream::in | std::fstream::binary;
// std::fstream pid_file(open_file(pid_path, mode));
// union
// {
// uint64_t pid;
// char pid_char[sizeof(uint64_t)];
// };
// if (!pid_file)
// return;
// pid_file.read(&pid_char[0], 8);
// ProcessInfo pi = open_process(pid);
// if (pi.handle == 0)
// return;
// std::string name = get_process_name(pi);
// if (name.find("crash-handler-process.exe") != std::string::npos) {
// kill(pi, -1);
// }
// close_process(pi);
// }
std::string get_temp_directory()
{
#ifdef WIN32
Expand Down

0 comments on commit 05f3c23

Please sign in to comment.