aboutsummaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorJoseph Koshy <jkoshy@FreeBSD.org>1998-06-17 12:58:43 +0000
committerJoseph Koshy <jkoshy@FreeBSD.org>1998-06-17 12:58:43 +0000
commita3e5bc4fb553a09a33906021a0c879e66eeb91e1 (patch)
tree27f4e12b729e9342edd61cb01d72711dd29dfb22 /usr.bin
parenta249e026050abb47eca27169f7d185e79f11d69d (diff)
downloadsrc-a3e5bc4fb553a09a33906021a0c879e66eeb91e1.tar.gz
src-a3e5bc4fb553a09a33906021a0c879e66eeb91e1.zip
Remove compile time dependency on ARG_MAX.
This fix only removes the dependency on compile time constants. The code has other (old) problems that need to be addressed. PR: 1791 Reviewed-by: bde, tegge
Notes
Notes: svn path=/head/; revision=37029
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/xargs/xargs.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.bin/xargs/xargs.c b/usr.bin/xargs/xargs.c
index 11cac933bc1e..d5cf5279970c 100644
--- a/usr.bin/xargs/xargs.c
+++ b/usr.bin/xargs/xargs.c
@@ -45,13 +45,12 @@ static const char copyright[] =
static char sccsid[] = "@(#)xargs.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
- "$Id$";
+ "$Id: xargs.c,v 1.5 1997/08/27 06:26:23 charnier Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/wait.h>
#include <err.h>
-#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -73,6 +72,7 @@ main(argc, argv, env)
register char *p, *bbp, *ebp, **bxp, **exp, **xp;
int cnt, indouble, insingle, nargs, nflag, nline, xflag;
char **av, *argp, **ep = env;
+ long arg_max;
/*
* POSIX.2 limits the exec line length to ARG_MAX - 2K. Running that
@@ -88,7 +88,9 @@ main(argc, argv, env)
* probably not worthwhile.
*/
nargs = 5000;
- nline = ARG_MAX - 4 * 1024;
+ if ((arg_max = sysconf(_SC_ARG_MAX)) == -1)
+ errx(1, "sysconf(_SC_ARG_MAX) failed");
+ nline = arg_max - 4 * 1024;
while (*ep) {
/* 1 byte for each '\0' */
nline -= strlen(*ep++) + 1 + sizeof(*ep);