*BSD News Article 51350


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!simtel!lll-winken.llnl.gov!uwm.edu!news.moneng.mei.com!news.inc.net!news.sprintlink.net!tank.news.pipex.net!pipex!sunsite.doc.ic.ac.uk!lyra.csx.cam.ac.uk!gi101
From: gi101@cus.cam.ac.uk (G. Ioannou)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: xargs and ARG_MAX
Date: 13 Sep 1995 19:05:42 GMT
Organization: University of Cambridge, England
Lines: 21
Message-ID: <437a26$bg3@lyra.csx.cam.ac.uk>
Reply-To: gi101@cam.ac.uk
NNTP-Posting-Host: bootes.cus.cam.ac.uk
Summary: What is ARG_MAX?
Keywords: xargs argument ARG_MAX


From the xargs(1) source code, xargs.c:

	 * POSIX.2 limits the exec line length to ARG_MAX - 2K.  Running that
	 * caused some E2BIG errors, so it was changed to ARG_MAX - 4K.  Given
	 * that the smallest argument is 2 bytes in length, this means that
	 * the number of arguments is limited to:
	 *
	 *	 (ARG_MAX - 4K - LENGTH(utility + arguments)) / 2.
	 *
	 * We arbitrarily limit the number of arguments to 5000.  This is
	 * allowed by POSIX.2 as long as the resulting minimum exec line is
	 * at least LINE_MAX.  Realloc'ing as necessary is possible, but
	 * probably not worthwhile.

Something similar to this is also stated in the manpage.  My
question is this: what is ARG_MAX, and therefore, what is the
maximum command line length in FreeBSD?

Thanx.
George.