Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Loading...
Searching...
No Matches
processes.hh File Reference
#include "nix/util/types.hh"
#include "nix/util/error.hh"
#include "nix/util/fun.hh"
#include "nix/util/file-descriptor.hh"
#include "nix/util/logging.hh"
#include "nix/util/ansicolor.hh"
#include "nix/util/os-string.hh"
#include <filesystem>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <unistd.h>
#include <signal.h>
#include <atomic>
#include <functional>
#include <map>
#include <sstream>
#include <optional>
#include <thread>

Go to the source code of this file.

Classes

class  nix::Pid
struct  nix::ProcessOptions
struct  nix::SpawnOptions
struct  nix::RunOptions
struct  nix::FdRedirection
class  nix::ExecError

Functions

void nix::killUser (uid_t uid)
pid_t nix::startProcess (fun< void()> processMain, const ProcessOptions &options=ProcessOptions())
const std::filesystem::path & nix::shProgram ()
std::string nix::runProgram (std::filesystem::path program, bool lookupPath=false, const OsStrings &args=OsStrings(), bool isInteractive=false)
std::pair< int, std::string > nix::runProgram (RunOptions &&options)
Pid nix::spawnProgram (const SpawnOptions &options, std::span< const FdRedirection > fdr)
 Spawn a program as a subprocess.
void nix::runProgram2 (const RunOptions &options)
std::string nix::statusToString (int status)
bool nix::statusOk (int status)

Function Documentation

◆ killUser()

void nix::killUser ( uid_t uid)

Kill all processes running under the specified uid by sending them a SIGKILL.

◆ runProgram()

std::string nix::runProgram ( std::filesystem::path program,
bool lookupPath = false,
const OsStrings & args = OsStrings(),
bool isInteractive = false )

Run a program and return its stdout in a string (i.e., like the shell backtick operator).

◆ shProgram()

const std::filesystem::path & nix::shProgram ( )

The POSIX shell used to run command strings with -c (build-time configurable via the sh-program option; always an absolute path).

◆ spawnProgram()

Pid nix::spawnProgram ( const SpawnOptions & options,
std::span< const FdRedirection > fdr )

Spawn a program as a subprocess.

Returns
Pid of the spawned process.
Exceptions
SysErrorif fork() or vfork() fail in the parent, ExecError if housekeeping fails with status code 127 (as does posix_spawn).
Parameters
fdrUnless specified, standard in, out and error are inherited. Redirections are applied in the same order in the child housekeeping. It's the callers responsibility to ensure that the redirected file descriptors are inheritable.

◆ statusToString()

std::string nix::statusToString ( int status)

Convert the exit status of a child as returned by wait() into an error string.