Files
lix/lix/libutil/current-process.hh
T
eldritch horrors 9ad8136825 libutil: always restore mounts from restoreProcessContext
daemons only need to restore the signal mask anyway, nothing else.

Change-Id: Id2a91f33ccf68f4d1af1bc526973a4bee066ff0b
2026-02-02 14:20:54 +00:00

37 lines
807 B
C++

#pragma once
///@file
#include <optional>
#include <sys/resource.h>
#include "lix/libutil/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();
/**
* Increase the stack size rlimit if it is currently smaller than `stackSize`.
*/
void ensureStackSizeAtLeast(rlim_t stackSize);
/**
* Restore the original inherited Unix process context (such as signal
* masks, stack size). This should generally be called after fork for a process
* intending to simply execve.
*
* See startSignalHandlerThread(), saveSignalMask().
*/
void restoreProcessContext();
/**
* @return the path of the current executable.
*/
std::optional<Path> getSelfExe();
}