diff options
Diffstat (limited to 'exec.c')
-rw-r--r-- | exec.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -89,9 +89,14 @@ static size_t bfs_exec_arg_max(const struct bfs_exec *execbuf) { arg_max -= sizeof(char *); bfs_exec_debug(execbuf, "ARG_MAX: %ld remaining after fixed arguments\n", arg_max); - // POSIX recommends subtracting 2048, for some wiggle room - // We subtract 4096 for extra insurance, based on some experimentation - arg_max -= 4096; + // Assume arguments are counted with the granularity of a single page, + // and allow two pages of headroom to account for rounding as well as + // any other data we may not be counting + long page_size = sysconf(_SC_PAGESIZE); + if (page_size < 4096) { + page_size = 4096; + } + arg_max -= 2*page_size; bfs_exec_debug(execbuf, "ARG_MAX: %ld remaining after headroom\n", arg_max); if (arg_max < 0) { |