2023-10-25 07:43:36 +03:00
|
|
|
#pragma once
|
|
|
|
///@file
|
|
|
|
|
|
|
|
#include <optional>
|
2023-09-03 00:35:16 +03:00
|
|
|
|
|
|
|
#ifndef _WIN32
|
|
|
|
# include <sys/resource.h>
|
|
|
|
#endif
|
2023-10-25 07:43:36 +03:00
|
|
|
|
|
|
|
#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.
|
|
|
|
*/
|
2024-05-18 14:09:56 +03:00
|
|
|
void setStackSize(size_t stackSize);
|
2023-10-25 07:43:36 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Restore the original inherited Unix process context (such as signal
|
|
|
|
* masks, stack size).
|
|
|
|
|
2023-09-03 00:35:16 +03:00
|
|
|
* See unix::startSignalHandlerThread(), unix::saveSignalMask().
|
2023-10-25 07:43:36 +03:00
|
|
|
*/
|
|
|
|
void restoreProcessContext(bool restoreMounts = true);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the path of the current executable.
|
|
|
|
*/
|
|
|
|
std::optional<Path> getSelfExe();
|
|
|
|
|
|
|
|
}
|