-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
All OS and IO operations should be moved out, leaving only some misc portable pure functions. This is useful to avoid copious CPP when doing things like Windows and Emscripten ports. Newly exposed functions to break cycles: - `restoreSignals` - `updateWindowSize`
- Loading branch information
1 parent
9bc7b4f
commit f1fc3e2
Showing
111 changed files
with
3,425 additions
and
2,630 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#include "util.hh" | ||
#include "editor-for.hh" | ||
#include "environment-variables.hh" | ||
|
||
namespace nix { | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#include "users.hh" | ||
#include "eval-cache.hh" | ||
#include "sqlite.hh" | ||
#include "eval.hh" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#include "users.hh" | ||
#include "globals.hh" | ||
#include "profiles.hh" | ||
#include "eval.hh" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#include "terminal.hh" | ||
#include "flake.hh" | ||
#include "eval.hh" | ||
#include "eval-settings.hh" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
#include <variant> | ||
|
||
#include "util.hh" | ||
#include "users.hh" | ||
|
||
#include "nixexpr.hh" | ||
#include "eval.hh" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#include "util.hh" | ||
#include "value/context.hh" | ||
|
||
#include <optional> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#include "cache.hh" | ||
#include "users.hh" | ||
#include "sqlite.hh" | ||
#include "sync.hh" | ||
#include "store-api.hh" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
|
||
#include "types.hh" | ||
#include "config.hh" | ||
#include "util.hh" | ||
|
||
#include <map> | ||
#include <limits> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#include "progress-bar.hh" | ||
#include "terminal.hh" | ||
#include "util.hh" | ||
#include "sync.hh" | ||
#include "store-api.hh" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#include "util.hh" | ||
#include "users.hh" | ||
#include "ambient-authority.hh" | ||
#include "environment-variables.hh" | ||
#include "file-system.hh" | ||
#include "signals.hh" | ||
#include "processes.hh" | ||
#include "unix-domain-socket.hh" | ||
#include "sync.hh" | ||
#include "finally.hh" | ||
#include "serialise.hh" | ||
#include "cgroup.hh" | ||
#include "child.hh" | ||
|
||
#include <array> | ||
#include <cctype> | ||
#include <cerrno> | ||
#include <climits> | ||
#include <cstdio> | ||
#include <cstdlib> | ||
#include <cstring> | ||
#include <future> | ||
#include <iostream> | ||
#include <mutex> | ||
#include <sstream> | ||
#include <thread> | ||
|
||
#include <fcntl.h> | ||
#include <grp.h> | ||
#include <pwd.h> | ||
#include <sys/ioctl.h> | ||
#include <sys/types.h> | ||
#include <sys/socket.h> | ||
#include <sys/wait.h> | ||
#include <sys/time.h> | ||
#include <sys/un.h> | ||
#include <unistd.h> | ||
|
||
#ifdef __APPLE__ | ||
#include <sys/syscall.h> | ||
#include <mach-o/dyld.h> | ||
#endif | ||
|
||
#ifdef __linux__ | ||
#include <sys/prctl.h> | ||
#include <sys/resource.h> | ||
#include <sys/mman.h> | ||
|
||
#include <cmath> | ||
#endif | ||
|
||
namespace nix { | ||
|
||
void commonChildInit() | ||
{ | ||
logger = makeSimpleLogger(); | ||
|
||
const static std::string pathNullDevice = "/dev/null"; | ||
restoreProcessContext(false); | ||
|
||
/* Put the child in a separate session (and thus a separate | ||
process group) so that it has no controlling terminal (meaning | ||
that e.g. ssh cannot open /dev/tty) and it doesn't receive | ||
terminal signals. */ | ||
if (setsid() == -1) | ||
throw SysError("creating a new session"); | ||
|
||
/* Dup stderr to stdout. */ | ||
if (dup2(STDERR_FILENO, STDOUT_FILENO) == -1) | ||
throw SysError("cannot dup stderr into stdout"); | ||
|
||
/* Reroute stdin to /dev/null. */ | ||
int fdDevNull = open(pathNullDevice.c_str(), O_RDWR); | ||
if (fdDevNull == -1) | ||
throw SysError("cannot open '%1%'", pathNullDevice); | ||
if (dup2(fdDevNull, STDIN_FILENO) == -1) | ||
throw SysError("cannot dup null device into stdin"); | ||
close(fdDevNull); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#pragma once | ||
///@file | ||
|
||
namespace nix { | ||
|
||
/** | ||
* Common initialisation performed in child processes. | ||
*/ | ||
void commonChildInit(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
#include "globals.hh" | ||
#include "hook-instance.hh" | ||
#include "file-system.hh" | ||
#include "child.hh" | ||
|
||
namespace nix { | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
|
||
#include "logging.hh" | ||
#include "serialise.hh" | ||
#include "processes.hh" | ||
|
||
namespace nix { | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
|
||
#include "derivation-goal.hh" | ||
#include "local-store.hh" | ||
#include "processes.hh" | ||
|
||
namespace nix { | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#include "crypto.hh" | ||
#include "file-system.hh" | ||
#include "util.hh" | ||
#include "globals.hh" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#include "derived-path-map.hh" | ||
#include "util.hh" | ||
|
||
namespace nix { | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.