aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/current-process.hh
diff options
context:
space:
mode:
authorTom Hubrecht <github@mail.hubrecht.ovh>2024-05-28 13:36:02 +0200
committerTom Hubrecht <github@mail.hubrecht.ovh>2024-05-29 11:01:34 +0200
commit2473e1253d37d4bbd3f7aad2ff269ad84747d527 (patch)
treed81cd79de634171914b978a265ae59ef91295f22 /src/libutil/current-process.hh
parent9a52e4688ca265155817817f373938428f023966 (diff)
util.{hh,cc}: Split out current-process.{hh,cc}
Change-Id: I77095b9d37e85310075bada7a076ccd482c28e47
Diffstat (limited to 'src/libutil/current-process.hh')
-rw-r--r--src/libutil/current-process.hh37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/libutil/current-process.hh b/src/libutil/current-process.hh
new file mode 100644
index 000000000..8d5a2791d
--- /dev/null
+++ b/src/libutil/current-process.hh
@@ -0,0 +1,37 @@
+#pragma once
+///@file
+
+#include <optional>
+#include <sys/resource.h>
+
+#include "types.hh"
+
+namespace nix {
+
+/**
+ * If cgroups are active, attempt to calculate the number of CPUs available.
+ * If cgroups are unavailable or if cpu.max is set to "max", return 0.
+ */
+unsigned int getMaxCPU();
+
+
+/**
+ * Change the stack size.
+ */
+void setStackSize(rlim_t stackSize);
+
+
+/**
+ * Restore the original inherited Unix process context (such as signal
+ * masks, stack size).
+
+ * See startSignalHandlerThread(), saveSignalMask().
+ */
+void restoreProcessContext(bool restoreMounts = true);
+
+/**
+ * @return the path of the current executable.
+ */
+std::optional<Path> getSelfExe();
+
+}