fixed broken stdin in processes

more logging
This commit is contained in:
isanae
2020-05-04 03:27:22 -04:00
parent a2c2350c26
commit adb97bac04
9 changed files with 29 additions and 16 deletions
+2 -2
View File
@@ -43,7 +43,7 @@ std::string reason_string(context::reason r)
case context::redownload: return "re-dl";
case context::rebuild: return "re-bd";
case context::reextract: return "re-ex";
case context::interrupted: return "int";
case context::interruption: return "int";
case context::cmd: return "cmd";
case context::std_out: return "stdout";
case context::std_err: return "stderr";
@@ -226,7 +226,7 @@ std::string context::make_log_string(reason r, level, std::string_view s) const
oss << s << " (happened because of --reextract)";
break;
case context::interrupted:
case context::interruption:
if (s.empty())
oss << "interrupted";
else
+3 -2
View File
@@ -26,8 +26,9 @@ public:
// an action was done because the --reextract option was set
reextract,
// something returned early because it was interrupted
interrupted,
// an action was done in case of interruption or because something
// was interrupted
interruption,
// command line of a process
cmd,
+1 -1
View File
@@ -72,7 +72,7 @@ void curl_downloader::join()
void curl_downloader::interrupt()
{
cx_.debug(context::interrupted, "will interrupt curl");
cx_.debug(context::interruption, "will interrupt curl");
interrupt_ = true;
}
+6 -4
View File
@@ -45,7 +45,8 @@ void delete_directory(const context& cx, const fs::path& p, flags f)
if (f & optional)
{
cx.trace(context::fs,
"not deleting dir " + p.string() + ", doesn't exist");
"not deleting dir " + p.string() + ", "
"doesn't exist (optional)");
return;
}
@@ -71,7 +72,8 @@ void delete_file(const context& cx, const fs::path& p, flags f)
if (f & optional)
{
cx.trace(context::fs,
"not deleting file " + p.string() + ", doesn't exist");
"not deleting file " + p.string() + ", "
"doesn't exist (optional)");
return;
}
@@ -232,8 +234,8 @@ void copy_file_to_dir_if_better(
if (f & optional)
{
cx.trace(context::fs,
"not copying " + file.string() + ", not found but "
"optional");
"not copying " + file.string() + ", "
"doesn't exist (optional)");
return;
}
+3 -2
View File
@@ -372,6 +372,7 @@ void process::do_run(const std::string& what)
auto process_stderr = impl_.stderr_pipe.create();
si.hStdError = process_stderr.get();
si.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
si.dwFlags = STARTF_USESTDHANDLES;
const std::string cmd = this_env::get("COMSPEC");
@@ -534,14 +535,14 @@ void process::on_timeout(bool& already_interrupted)
if (pid == 0)
{
cx_->error(context::cmd,
cx_->trace(context::cmd,
"process id is 0, terminating instead");
::TerminateProcess(impl_.handle.get(), 0xffff);
}
else
{
cx_->error(context::cmd,
cx_->trace(context::cmd,
"sending sigint to " + std::to_string(pid));
GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, pid);
+2
View File
@@ -50,6 +50,8 @@ void cmake::do_run()
{
if (conf::rebuild())
{
cx_->trace(context::rebuild, "deleting all generator directories");
for (auto&& [k, g] : all_generators())
{
op::delete_directory(*cx_,
+1 -1
View File
@@ -88,7 +88,7 @@ void downloader::do_run()
if (interrupted())
{
cx_->trace(context::interrupted, "");
cx_->trace(context::interruption, "");
return;
}
+1 -1
View File
@@ -48,7 +48,7 @@ void tool::interrupt()
{
if (!interrupted_)
{
cx_->info(context::interrupted, "interrupting " + name_);
cx_->info(context::interruption, "interrupting " + name_);
interrupted_ = true;
do_interrupt();
}
+10 -3
View File
@@ -111,7 +111,10 @@ interruption_file::interruption_file(
: cx_(cx), dir_(std::move(dir)), name_(std::move(name))
{
if (fs::exists(file()))
cx_.trace(context::generic, "found interrupt file " + file().string());
{
cx_.trace(context::interruption,
"found interrupt file " + file().string());
}
}
bool interruption_file::exists() const
@@ -126,13 +129,17 @@ fs::path interruption_file::file() const
void interruption_file::create()
{
cx_.trace(context::generic, "creating interrupt file " + file().string());
cx_.trace(context::interruption,
"creating interrupt file " + file().string());
op::touch(cx_, file());
}
void interruption_file::remove()
{
cx_.trace(context::generic, "removing interrupt file " + file().string());
cx_.trace(context::interruption,
"removing interrupt file " + file().string());
op::delete_file(cx_, file());
}