Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Loading...
Searching...
No Matches
shared.hh File Reference
#include "nix/util/file-descriptor.hh"
#include "nix/util/processes.hh"
#include "nix/util/args.hh"
#include "nix/util/args/root.hh"
#include "nix/main/common-args.hh"
#include "nix/store/path.hh"
#include "nix/store/derived-path.hh"
#include <signal.h>

Go to the source code of this file.

Classes

struct  nix::LegacyArgs
class  nix::RunPager

Functions

void nix::initNix (bool loadConfig=true)
void nix::parseCmdLine (int argc, char **argv, fun< bool(Strings::iterator &arg, const Strings::iterator &end)> parseArg)
void nix::parseCmdLine (const std::string &programName, const Strings &args, fun< bool(Strings::iterator &arg, const Strings::iterator &end)> parseArg)
void nix::printVersion (const std::string &programName)
void nix::printGCWarning ()
void nix::printMissing (ref< Store > store, const std::vector< DerivedPath > &paths, Verbosity lvl=lvlInfo)
void nix::printMissing (ref< Store > store, const MissingPaths &missing, Verbosity lvl=lvlInfo)
std::string nix::getArg (const std::string &opt, Strings::iterator &i, const Strings::iterator &end)
template<class N>
N nix::getIntArg (const std::string &opt, Strings::iterator &i, const Strings::iterator &end, bool allowUnit)
void nix::printFreed (bool dryRun, const GCResults &results)
void nix::detectStackOverflow ()
void nix::defaultStackOverflowHandler (siginfo_t *info, void *ctx)

Variables

volatile ::sig_atomic_t nix::blockInt
fun< void(siginfo_t *info, void *ctx)> nix::stackOverflowHandler

Function Documentation

◆ defaultStackOverflowHandler()

void nix::defaultStackOverflowHandler ( siginfo_t * info,
void * ctx )

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.

◆ detectStackOverflow()

void nix::detectStackOverflow ( )

Install a SIGSEGV handler to detect stack overflows.

◆ initNix()

void nix::initNix ( bool loadConfig = true)

Don't forget to call initPlugins() after settings are initialized!

Parameters
loadConfigWhether to load configuration from nix.conf, NIX_CONFIG, etc. May be disabled for unit tests.

◆ printGCWarning()

void nix::printGCWarning ( )

Ugh. No better place to put this.

Variable Documentation

◆ stackOverflowHandler

fun<void(siginfo_t * info, void * ctx)> nix::stackOverflowHandler
extern

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.