diff options
author | Joseph Koshy <jkoshy@FreeBSD.org> | 1998-06-17 11:33:10 +0000 |
---|---|---|
committer | Joseph Koshy <jkoshy@FreeBSD.org> | 1998-06-17 11:33:10 +0000 |
commit | c7bca09356774cbd72e4da0247bac1cb49f21e8a (patch) | |
tree | 2960a556dd0133caea5067f3611953262fc5878a /bin/ps/fmt.c | |
parent | 6943ec8018adbaba26d715e7219005f1951e1ccf (diff) | |
download | src-c7bca09356774cbd72e4da0247bac1cb49f21e8a.tar.gz src-c7bca09356774cbd72e4da0247bac1cb49f21e8a.zip |
Remove compile time dependency on ARG_MAX.
PR: 1791 (partial)
Reviewed by: Bruce Evans <bde@freebsd.org>, Tor Egge <tegge@freebsd.org>
Notes
Notes:
svn path=/head/; revision=37027
Diffstat (limited to 'bin/ps/fmt.c')
-rw-r--r-- | bin/ps/fmt.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/bin/ps/fmt.c b/bin/ps/fmt.c index 2cb39bfdab21..76eb78c21c21 100644 --- a/bin/ps/fmt.c +++ b/bin/ps/fmt.c @@ -36,7 +36,7 @@ static char sccsid[] = "@(#)fmt.c 8.4 (Berkeley) 4/15/94"; #endif static const char rcsid[] = - "$Id$"; + "$Id: fmt.c,v 1.11 1998/05/15 06:29:15 charnier Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -46,6 +46,7 @@ static const char rcsid[] = #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> #include <vis.h> #include "ps.h" @@ -60,8 +61,16 @@ static char * shquote(argv) char **argv; { + long arg_max; char **p, *dst, *src; - static char buf[4*ARG_MAX]; /* XXX */ + static char *buf = NULL; + + if (buf == NULL) { + if ((arg_max = sysconf(_SC_ARG_MAX)) == -1) + errx(1, "sysconf _SC_ARG_MAX failed"); + if ((buf = malloc((4 * arg_max) + 1)) == NULL) + errx(1, "malloc failed"); + } if (*argv == 0) { buf[0] = 0; |