Skip to content

Commit

Permalink
Get SC_ARG_MAX from os.sysconf(), not C
Browse files Browse the repository at this point in the history
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
  • Loading branch information
rlbdv committed Jun 28, 2015
1 parent bdfc387 commit 5706d66
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
12 changes: 0 additions & 12 deletions lib/bup/_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
4 changes: 3 additions & 1 deletion lib/bup/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

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
Expand Down Expand Up @@ -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)."""
Expand Down

0 comments on commit 5706d66

Please sign in to comment.