xargs: fix sysconf(_SC_ARG_MAX)

the minimum space required by environment variables isn't clearly defined by
POSIX afaik.
This commit is contained in:
Hiltjo Posthuma 2015-03-27 22:43:55 +01:00
parent 7ebf02d749
commit 67ca2428d5

11
xargs.c
View File

@ -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':