From 67ca2428d5554e251651e39ef6d74cdcddcefa28 Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Fri, 27 Mar 2015 22:43:55 +0100 Subject: [PATCH] xargs: fix sysconf(_SC_ARG_MAX) the minimum space required by environment variables isn't clearly defined by POSIX afaik. --- xargs.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/xargs.c b/xargs.c index 28dfaef..d39679e 100644 --- a/xargs.c +++ b/xargs.c @@ -191,16 +191,15 @@ usage(void) int main(int argc, char *argv[]) { - int leftover = 0; + int leftover = 0, i; size_t argsz, argmaxsz; + size_t arglen, a; char *arg = ""; - int i, a; - argmaxsz = sysconf(_SC_ARG_MAX); - if (argmaxsz < 0) - eprintf("sysconf:"); + if ((argmaxsz = sysconf(_SC_ARG_MAX)) == (size_t)-1) + argmaxsz = _POSIX_ARG_MAX; /* Leave some room for environment variables */ - argmaxsz -= 4 * 1024; + argmaxsz -= 4096; ARGBEGIN { case 'n':