mirror of
https://github.com/NixOS/nix.git
synced 2025-11-09 03:56:01 +01:00
setStackSize: Warn when the desired stack size can't be set
This commit is contained in:
parent
f6aeca0522
commit
2349c3dbde
1 changed files with 10 additions and 0 deletions
|
|
@ -65,6 +65,16 @@ void setStackSize(size_t stackSize)
|
|||
struct rlimit limit;
|
||||
if (getrlimit(RLIMIT_STACK, &limit) == 0 && static_cast<size_t>(limit.rlim_cur) < stackSize) {
|
||||
savedStackSize = limit.rlim_cur;
|
||||
if (limit.rlim_max < static_cast<rlim_t>(stackSize)) {
|
||||
logger->log(
|
||||
lvlWarn,
|
||||
HintFmt(
|
||||
"Stack size hard limit is %1%, which is less than the desired %2%. If possible, increase the hard limit, e.g. with 'ulimit -Hs %3%'.",
|
||||
limit.rlim_max,
|
||||
stackSize,
|
||||
stackSize / 1024)
|
||||
.str());
|
||||
}
|
||||
auto requestedSize = std::min(static_cast<rlim_t>(stackSize), limit.rlim_max);
|
||||
limit.rlim_cur = requestedSize;
|
||||
if (setrlimit(RLIMIT_STACK, &limit) != 0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue