setStackSize: Warn when the desired stack size can't be set
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user