aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/util.cc
AgeCommit message (Collapse)Author
2021-10-13Non-blocking garbage collectorEelco Dolstra
The garbage collector no longer blocks other processes from adding/building store paths or adding GC roots. To prevent the collector from deleting store paths just added by another process, processes need to connect to the garbage collector via a Unix domain socket to register new temporary roots.
2021-10-06Don't reset the logger in a vforkEelco Dolstra
9c766a40cbbd3a350a9582d0fd8201e3361a63b2 broke logging from the daemon, because commonChildInit is called when starting the build hook in a vfork, so it ends up resetting the parent's logger. So don't vfork. It might be best to get rid of vfork altogether, but that may cause problems, e.g. when we call an external program like git from the evaluator.
2021-10-05Show failing PIDEelco Dolstra
2021-10-05TypoEelco Dolstra
2021-10-05Connect/bind Unix domain sockets in a child processEelco Dolstra
In the child process, we can do a chdir() and avoid the problem of the path not fitting into sockaddr_un.
2021-09-27Fix 'error: reading a line: Input/output error' in startBuilder()Eelco Dolstra
With -vvvv, the ProgressBar was polluting the stderr of the child, messing up its \2 message to the parent.
2021-09-14Fix macOS buildEelco Dolstra
2021-09-13RunOptions: Use designated initializersEelco Dolstra
Also get rid of _killStderr because it wasn't actually checked anywhere.
2021-09-08Add missing include in util.ccNaïm Favier
2021-07-30libutil: initialize the base64 decode array only onceAndreas Rammhold
Previously, despite having a boolean that tracked initialization, the decode characters have been "calculated" every single time a base64 string was being decoded. With this change we only initialize the decode array once in a thread-safe manner.
2021-07-24libutil: use uniform initialization in _deletePathAlyssa Ross
Otherwise I get a compiler error when building for NetBSD: src/libutil/util.cc: In function 'void nix::_deletePath(const Path&, uint64_t&)': src/libutil/util.cc:438:17: error: base operand of '->' is not a pointer 438 | AutoCloseFD dirfd(open(dir.c_str(), O_RDONLY)); | ^~~~~ src/libutil/util.cc:439:10: error: 'dirfd' was not declared in this scope 439 | if (!dirfd) { | ^~~~~ src/libutil/util.cc:444:17: error: 'dirfd' was not declared in this scope 444 | _deletePath(dirfd.get(), path, bytesFreed); | ^~~~~
2021-07-20deletePath(): Return ENFILE instead of EBADF when out of file descriptorsEelco Dolstra
Also remove an erroneous comment.
2021-07-02Add $NO_COLOR check to ANSI escape conditionsYestin L. Harrison
2021-07-01Respect TERM=dumb more consistentlyYestin L. Harrison
2021-05-18Fix extra slash in canonPath outputMatthew Bauer
When you have a symlink like: /tmp -> ./private/tmp you need to resolve ./private/tmp relative to /tmp’s dir: ‘/’. Unlike any other path output by dirOf, / ends with a slash. We don’t want trailing slashes here since we will append another slash in the next comoponent, so clear s like we would if it was a symlink to an absoute path. This should fix at least part of the issue in https://github.com/NixOS/nix/issues/4822, will need confirmation that it actually fixes the problem to close though. Introduced in f3f228700a52857fe6e8632df4e935551ea219ff.
2021-04-15Merge pull request #4679 from ony/feature/one-pass-canon-pathEelco Dolstra
Optimize canonPath to resolve relative symlinks in one pass
2021-04-07Restore stack size in child processesEelco Dolstra
Fixes #4673.
2021-04-07restoreSignals() + restoreAffinity() -> restoreProcessContext()Eelco Dolstra
2021-04-07PathSubstitutionGoal: Clean up pipeEelco Dolstra
If there were many top-level goals (which are not destroyed until the very end), commands like $ nix copy --to 'ssh://localhost?remote-store=/tmp/nix' \ /run/current-system --no-check-sigs --substitute-on-destination could fail with "Too many open files". So now we do some explicit cleanup from amDone(). It would be cleaner to separate goals from their temporary internal state, but that would be a bigger refactor.
2021-03-31canonPath in one passMykola Orliuk
2021-03-26Fix some typosEelco Dolstra
Fixes #4671.
2021-02-07libutil: EPERM from kill(-1, ...) is fineAlyssa Ross
I tested a trivial program that called kill(-1, SIGKILL), which was run as the only process for an unpriveleged user, on Linux and FreeBSD. On Linux, kill reported success, while on FreeBSD it failed with EPERM. POSIX says: > If pid is -1, sig shall be sent to all processes (excluding an > unspecified set of system processes) for which the process has > permission to send that signal. and > The kill() function is successful if the process has permission to > send sig to any of the processes specified by pid. If kill() fails, > no signal shall be sent. and > [EPERM] > The process does not have permission to send the signal to any > receiving process. My reading of this is that kill(-1, ...) may fail with EPERM when there are no other processes to kill (since the current process is ignored). Since kill(-1, ...) only attempts to kill processes the user has permission to kill, it can't mean that we tried to do something we didn't have permission to kill, so it should be fine to interpret EPERM the same as success here for any POSIX-compliant system. This fixes an issue that Mic92 encountered[1] when he tried to review a Nixpkgs PR on FreeBSD. [1]: https://github.com/NixOS/nixpkgs/pull/81459#issuecomment-606073668
2021-01-21Remove trailing whitespaceEelco Dolstra
2020-12-02read(): Use char * instead of unsigned char *Eelco Dolstra
This gets rid of some pointless casts.
2020-12-02Sink: Use std::string_viewEelco Dolstra
2020-12-02writeFull/writeFile: Use std::string_viewEelco Dolstra
2020-12-01replaceStrings(): Use std::string_viewEelco Dolstra
2020-11-16filterANSIEscapes(): Handle UTF-8 charactersEelco Dolstra
2020-10-11Split out `commonChildInit`John Ericson
2020-10-09Remove LazyEelco Dolstra
This fixes a crash during startup when compiling Nix as a single compilation unit.
2020-10-09writeFile(): Add error context to writeFull() failureEelco Dolstra
Issue #4092.
2020-10-06Factor out common showBytes()Eelco Dolstra
2020-08-20Allow 'nix' subcommands to provide docs in Markdown formatEelco Dolstra
2020-08-04Merge remote-tracking branch 'upstream/master' into better-ca-parse-errorsJohn Ericson
2020-08-03Delete compressed NARsEelco Dolstra
Fixes #3891.
2020-07-30Merge branch 'master' of github.com:NixOS/nix into better-ca-parse-errorsCarlo Nucera
2020-07-30unsigned long long -> uint64_tEelco Dolstra
2020-07-27Merge branch 'hash-always-has-type' of github.com:obsidiansystems/nix into ↵John Ericson
better-ca-parse-errors
2020-07-24createUnixDomainSocket(): Fix off-by-one error in copying the socket pathEelco Dolstra
Reported by Kane York.
2020-07-16Merge branch 'hash-always-has-type' of github.com:obsidiansystems/nix into ↵John Ericson
better-ca-parse-errors
2020-07-01Remove unused importCarlo Nucera
2020-07-01Correct FIXMEs in libfetchersCarlo Nucera
2020-07-01Fixed build, we still have test errorsCarlo Nucera
2020-06-26Merge remote-tracking branch 'origin/master' into flakesEelco Dolstra
2020-06-17Merge pull request #3707 from p01arst0rm/outdated-function-fixEelco Dolstra
replaced uncaught_exception with uncaught_exceptions
2020-06-17Merge remote-tracking branch 'origin/master' into flakesEelco Dolstra
2020-06-17appended ' __attribute__((weak)); ' to 'extern char * * environ 'p01arst0rm
2020-06-17replaced uncaught_exception with uncaught_exceptionsp01arst0rm
2020-06-15Remove trailing whitespaceEelco Dolstra
2020-06-15Merge branch 'errors-phase-2' of https://github.com/bburdette/nixEelco Dolstra