From: Rob Browning Date: Sun, 28 Jun 2015 16:35:36 +0000 (-0500) Subject: Get SC_ARG_MAX from os.sysconf(), not C X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=5706d66f426d6a10cff422a68db0287aea386912;p=packages%2Fb%2Fbup.git Get SC_ARG_MAX from os.sysconf(), not C Signed-off-by: Rob Browning Tested-by: Rob Browning --- diff --git a/lib/bup/_helpers.c b/lib/bup/_helpers.c index cfdbc8a..88653ac 100644 --- a/lib/bup/_helpers.c +++ b/lib/bup/_helpers.c @@ -1516,18 +1516,6 @@ PyMODINIT_FUNC init_helpers(void) Py_DECREF(value); } #endif - { - PyObject *value; - const long arg_max = sysconf(_SC_ARG_MAX); - if (arg_max == -1) - { - fprintf(stderr, "Cannot find SC_ARG_MAX, please report a bug.\n"); - exit(1); - } - value = INTEGER_TO_PY(arg_max); - PyObject_SetAttrString(m, "SC_ARG_MAX", value); - Py_DECREF(value); - } #pragma clang diagnostic pop // ignored "-Wtautological-compare" e = getenv("BUP_FORCE_TTY"); diff --git a/lib/bup/helpers.py b/lib/bup/helpers.py index f1c6084..9e42884 100644 --- a/lib/bup/helpers.py +++ b/lib/bup/helpers.py @@ -9,6 +9,8 @@ import hashlib, heapq, math, operator, time, grp, tempfile from bup import _helpers +sc_arg_max = os.sysconf('SC_ARG_MAX') + # This function should really be in helpers, not in bup.options. But we # want options.py to be standalone so people can include it in other projects. from bup.options import _tty_width @@ -214,7 +216,7 @@ def _argmax_args_size(args): return sum(len(x) + 1 + sizeof(c_void_p) for x in args) -def batchpipe(command, args, preexec_fn=None, arg_max=_helpers.SC_ARG_MAX): +def batchpipe(command, args, preexec_fn=None, arg_max=sc_arg_max): """If args is not empty, yield the output produced by calling the command list with args as a sequence of strings (It may be necessary to return multiple strings in order to respect ARG_MAX)."""