aboutsummaryrefslogtreecommitdiff
path: root/src/libmain
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2023-04-07 20:39:04 -0400
committerJohn Ericson <John.Ericson@Obsidian.Systems>2023-04-07 20:39:04 -0400
commitfd21f9d76e53228acbbbfc05726059d48243f6d2 (patch)
tree95b50f8613e33ba2b81954cbd8b986c1d9be473b /src/libmain
parent5d56e2daf70788fae532d1875edbd4e9bdb5afef (diff)
parent4411c7d7e0242c9f9f8ae3f4d0473c53df12edfb (diff)
Merge remote-tracking branch 'upstream/master' into path-info
Diffstat (limited to 'src/libmain')
-rw-r--r--src/libmain/common-args.hh1
-rw-r--r--src/libmain/loggers.hh1
-rw-r--r--src/libmain/progress-bar.cc15
-rw-r--r--src/libmain/progress-bar.hh1
-rw-r--r--src/libmain/shared.hh61
5 files changed, 55 insertions, 24 deletions
diff --git a/src/libmain/common-args.hh b/src/libmain/common-args.hh
index f180d83ce..e7ed0d934 100644
--- a/src/libmain/common-args.hh
+++ b/src/libmain/common-args.hh
@@ -1,4 +1,5 @@
#pragma once
+///@file
#include "args.hh"
diff --git a/src/libmain/loggers.hh b/src/libmain/loggers.hh
index f3c759193..e5721420c 100644
--- a/src/libmain/loggers.hh
+++ b/src/libmain/loggers.hh
@@ -1,4 +1,5 @@
#pragma once
+///@file
#include "types.hh"
diff --git a/src/libmain/progress-bar.cc b/src/libmain/progress-bar.cc
index 024259584..6600ec177 100644
--- a/src/libmain/progress-bar.cc
+++ b/src/libmain/progress-bar.cc
@@ -72,6 +72,7 @@ private:
uint64_t corruptedPaths = 0, untrustedPaths = 0;
bool active = true;
+ bool paused = false;
bool haveUpdate = true;
};
@@ -120,6 +121,18 @@ public:
updateThread.join();
}
+ void pause() override {
+ state_.lock()->paused = true;
+ writeToStderr("\r\e[K");
+ }
+
+ void resume() override {
+ state_.lock()->paused = false;
+ writeToStderr("\r\e[K");
+ state_.lock()->haveUpdate = true;
+ updateCV.notify_one();
+ }
+
bool isVerbose() override
{
return printBuildLogs;
@@ -339,7 +352,7 @@ public:
auto nextWakeup = std::chrono::milliseconds::max();
state.haveUpdate = false;
- if (!state.active) return nextWakeup;
+ if (state.paused || !state.active) return nextWakeup;
std::string line;
diff --git a/src/libmain/progress-bar.hh b/src/libmain/progress-bar.hh
index 3a76f8448..c3c6e3833 100644
--- a/src/libmain/progress-bar.hh
+++ b/src/libmain/progress-bar.hh
@@ -1,4 +1,5 @@
#pragma once
+///@file
#include "logging.hh"
diff --git a/src/libmain/shared.hh b/src/libmain/shared.hh
index 1715374a6..7a9e83c6c 100644
--- a/src/libmain/shared.hh
+++ b/src/libmain/shared.hh
@@ -1,4 +1,5 @@
#pragma once
+///@file
#include "util.hh"
#include "args.hh"
@@ -24,7 +25,9 @@ public:
int handleExceptions(const std::string & programName, std::function<void()> fun);
-/* Don't forget to call initPlugins() after settings are initialized! */
+/**
+ * Don't forget to call initPlugins() after settings are initialized!
+ */
void initNix();
void parseCmdLine(int argc, char * * argv,
@@ -35,7 +38,9 @@ void parseCmdLine(const std::string & programName, const Strings & args,
void printVersion(const std::string & programName);
-/* Ugh. No better place to put this. */
+/**
+ * Ugh. No better place to put this.
+ */
void printGCWarning();
class Store;
@@ -74,11 +79,15 @@ struct LegacyArgs : public MixCommonArgs
};
-/* Show the manual page for the specified program. */
+/**
+ * Show the manual page for the specified program.
+ */
void showManPage(const std::string & name);
-/* The constructor of this class starts a pager if stdout is a
- terminal and $PAGER is set. Stdout is redirected to the pager. */
+/**
+ * The constructor of this class starts a pager if stdout is a
+ * terminal and $PAGER is set. Stdout is redirected to the pager.
+ */
class RunPager
{
public:
@@ -109,28 +118,34 @@ struct PrintFreed
};
-/* Install a SIGSEGV handler to detect stack overflows. */
+/**
+ * Install a SIGSEGV handler to detect stack overflows.
+ */
void detectStackOverflow();
-/* Pluggable behavior to run in case of a stack overflow.
-
- Default value: defaultStackOverflowHandler.
-
- This is called by the handler installed by detectStackOverflow().
-
- This gives Nix library consumers a limit opportunity to report the error
- condition. The handler should exit the process.
- See defaultStackOverflowHandler() for a reference implementation.
-
- NOTE: Use with diligence, because this runs in the signal handler, with very
- limited stack space and a potentially a corrupted heap, all while the failed
- thread is blocked indefinitely. All functions called must be reentrant. */
+/**
+ * Pluggable behavior to run in case of a stack overflow.
+ *
+ * Default value: defaultStackOverflowHandler.
+ *
+ * This is called by the handler installed by detectStackOverflow().
+ *
+ * This gives Nix library consumers a limit opportunity to report the error
+ * condition. The handler should exit the process.
+ * See defaultStackOverflowHandler() for a reference implementation.
+ *
+ * NOTE: Use with diligence, because this runs in the signal handler, with very
+ * limited stack space and a potentially a corrupted heap, all while the failed
+ * thread is blocked indefinitely. All functions called must be reentrant.
+ */
extern std::function<void(siginfo_t * info, void * ctx)> stackOverflowHandler;
-/* The default, robust implementation of stackOverflowHandler.
-
- Prints an error message directly to stderr using a syscall instead of the
- logger. Exits the process immediately after. */
+/**
+ * The default, robust implementation of stackOverflowHandler.
+ *
+ * Prints an error message directly to stderr using a syscall instead of the
+ * logger. Exits the process immediately after.
+ */
void defaultStackOverflowHandler(siginfo_t * info, void * ctx);
}