Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Loading...
Searching...
No Matches
current-process.hh File Reference
#include <filesystem>
#include <optional>
#include <chrono>
#include <sys/resource.h>
#include "nix/util/types.hh"

Go to the source code of this file.

Functions

std::chrono::microseconds nix::getCpuUserTime ()
unsigned int nix::getMaxCPU ()
void nix::ensureStackSizeAtLeast (size_t stackSize)
void nix::restoreProcessContext (bool restoreMounts)
std::optional< std::filesystem::path > nix::getSelfExe ()

Function Documentation

◆ ensureStackSizeAtLeast()

void nix::ensureStackSizeAtLeast ( size_t stackSize)

Increase the RLIMIT_STACK rlimit if it is currently smaller than stackSize.

Note
Don't call this on Darwin. We set the stack size of the thread group leader via a linker option instead to avoid mucking with process-global state.
Not thread safe. Calls to this should be wrapped in a std::call_once.

◆ getCpuUserTime()

std::chrono::microseconds nix::getCpuUserTime ( )

Get the current process's user space CPU time.

◆ getMaxCPU()

unsigned int nix::getMaxCPU ( )

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.

◆ getSelfExe()

std::optional< std::filesystem::path > nix::getSelfExe ( )
Returns
the path of the current executable.

◆ restoreProcessContext()

void nix::restoreProcessContext ( bool restoreMounts = true)

Restore the original inherited Unix process context (such as signal masks, stack size).

See unix::startSignalHandlerThread(), unix::saveSignalMask().