[hackers] [sbase] xargs: fix sysconf(_SC_ARG_MAX) || Hiltjo Posthuma

From: <git_AT_suckless.org>
Date: Sat, 28 Mar 2015 22:03:53 +0100 (CET)

commit 67ca2428d5554e251651e39ef6d74cdcddcefa28
Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Fri Mar 27 22:43:55 2015 +0100

    xargs: fix sysconf(_SC_ARG_MAX)
    
    the minimum space required by environment variables isn't clearly defined by
    POSIX afaik.

diff --git a/xargs.c b/xargs.c
index 28dfaef..d39679e 100644
--- a/xargs.c
+++ b/xargs.c
_AT_@ -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':
Received on Sat Mar 28 2015 - 22:03:53 CET

This archive was generated by hypermail 2.3.0 : Sat Mar 28 2015 - 22:12:33 CET