diff options
author | jkoshy <jkoshy@FreeBSD.org> | 1998-06-17 11:33:10 +0000 |
---|---|---|
committer | jkoshy <jkoshy@FreeBSD.org> | 1998-06-17 11:33:10 +0000 |
commit | e27dc1bad82c6c337783ab21d315a681dd3872bf (patch) | |
tree | 100ef4a037237788aad9832ca6ca4fabcf3861f1 /bin/ps | |
parent | a7dfca09c3f2ebe22fe2a15f06bf835fa61ee9ac (diff) | |
download | FreeBSD-src-e27dc1bad82c6c337783ab21d315a681dd3872bf.zip FreeBSD-src-e27dc1bad82c6c337783ab21d315a681dd3872bf.tar.gz |
Remove compile time dependency on ARG_MAX.
PR: 1791 (partial)
Reviewed by: Bruce Evans <bde@freebsd.org>, Tor Egge <tegge@freebsd.org>
Diffstat (limited to 'bin/ps')
-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 2cb39bf..76eb78c 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; |