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

Go to the source code of this file.

Classes

struct  nix::LegacyArgs
 
class  nix::RunPager
 
struct  nix::PrintFreed
 

Functions

int nix::handleExceptions (const std::string &programName, std::function< void()> fun)
 
void nix::initNix (bool loadConfig)
 
void nix::parseCmdLine (int argc, char **argv, std::function< bool(Strings::iterator &arg, const Strings::iterator &end)> parseArg)
 
void nix::parseCmdLine (const std::string &programName, const Strings &args, std::function< 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)
 
void nix::printMissing (ref< Store > store, const StorePathSet &willBuild, const StorePathSet &willSubstitute, const StorePathSet &unknown, uint64_t downloadSize, uint64_t narSize, Verbosity lvl)
 
std::string nix::getArg (const std::string &opt, Strings::iterator &i, const Strings::iterator &end)
 
template<class N>
nix::getIntArg (const std::string &opt, Strings::iterator &i, const Strings::iterator &end, bool allowUnit)
 
std::string nix::showBytes (uint64_t bytes)
 
void nix::detectStackOverflow ()
 
void nix::defaultStackOverflowHandler (siginfo_t *info, void *ctx)
 

Variables

volatile ::sig_atomic_t nix::blockInt
 
std::function< 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

std::function<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.