Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Loading...
Searching...
No Matches
signals.hh File Reference
#include "nix/util/types.hh"
#include "nix/util/error.hh"
#include "nix/util/fun.hh"
#include "nix/util/logging.hh"
#include <functional>
#include "nix/util/signals-impl.hh"

Go to the source code of this file.

Classes

struct  nix::InterruptCallback

Macros

#define NIX_SIG_MULTI_INT   SIGTSTP

Enumerations

enum class  nix::SignalType { Int , Stop , Cont , Winch }

Functions

void nix::checkInterrupt ()
 nix::MakeError (Interrupted, BaseError)
 nix::MakeError (Cancelled, BaseError)
std::unique_ptr< InterruptCallback > nix::createSignalCallback (SignalType type, fun< void()> callback)
std::unique_ptr< InterruptCallback > nix::createInterruptCallback (fun< void()> callback)

Enumeration Type Documentation

◆ SignalType

enum class nix::SignalType
strong

Portable identifiers for the signal events that callbacks can be registered for via createSignalCallback().

Enumerator
Int 

SIGINT/SIGTERM/SIGHUP, or a programmatic triggerInterrupt().

Stop 

SIGTSTP, called just before the process stops itself.

Cont 

SIGCONT, i.e. the process was resumed after being stopped.

Winch 

SIGWINCH, i.e. the terminal size changed.

Function Documentation

◆ checkInterrupt()

void nix::checkInterrupt ( )
inline
Note
Does nothing on Windows

Throw Interrupted exception if the process has been interrupted.

Call this in long-running loops and between slow operations to terminate them as needed.

◆ createInterruptCallback()

std::unique_ptr< InterruptCallback > nix::createInterruptCallback ( fun< void()> callback)
inline

Register a function that gets called on SIGINT (in a non-signal context).

Note
Does nothing on Windows

◆ createSignalCallback()

std::unique_ptr< InterruptCallback > nix::createSignalCallback ( SignalType type,
fun< void()> callback )
inline

Register a function that gets called from the signal handler thread (in a non-signal context) when the given signal type is received.

Note
Does nothing on Windows

◆ MakeError()

nix::MakeError ( Interrupted ,
BaseError  )
Note
Never will happen on Windows