From f92f1d0181853b989f9377debb56902e3e21c9a8 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 22 Jun 2014 13:54:40 +0200 Subject: find: use sysconf(_SC_ARG_MAX) to determine the command-line size limit The find utility uses a hardcoded value of 32 * 1024 as the limit of the command-line length when calling 'find -exec ... {} +'. This results in over 4 times more execve() calls than in coreutils' find. This patch uses the limit defined in system headers. Based on the patch by Bartosz Golaszewski . Signed-off-by: Denys Vlasenko --- libbb/Kbuild.src | 1 + libbb/sysconf.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 libbb/sysconf.c (limited to 'libbb') diff --git a/libbb/Kbuild.src b/libbb/Kbuild.src index 6578d1171..62680bd52 100644 --- a/libbb/Kbuild.src +++ b/libbb/Kbuild.src @@ -92,6 +92,7 @@ lib-y += skip_whitespace.o lib-y += speed_table.o lib-y += str_tolower.o lib-y += strrstr.o +lib-y += sysconf.o lib-y += time.o lib-y += trim.o lib-y += u_signal_names.o diff --git a/libbb/sysconf.c b/libbb/sysconf.c new file mode 100644 index 000000000..c5fa5e001 --- /dev/null +++ b/libbb/sysconf.c @@ -0,0 +1,16 @@ +/* vi: set sw=4 ts=4: */ +/* + * Various system configuration helpers. + * + * Copyright (C) 2014 Bartosz Golaszewski + * + * Licensed under GPLv2 or later, see file LICENSE in this source tree. + */ +#include "libbb.h" + +#if defined _SC_ARG_MAX +unsigned FAST_FUNC bb_arg_max(void) +{ + return sysconf(_SC_ARG_MAX); +} +#endif -- cgit v1.2.3