changeset 19863:bd953f563517

mx: followup fix for SC_ARG_MAX, add more assetions
author Gilles Duboscq <gilles.m.duboscq@oracle.com>
date Mon, 16 Mar 2015 12:23:11 +0100
parents e808c8324035
children 51da1608115e
files mxtool/mx.py
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mxtool/mx.py	Sun Mar 15 16:22:37 2015 +0100
+++ b/mxtool/mx.py	Mon Mar 16 12:23:11 2015 +0100
@@ -2823,13 +2823,16 @@
         else:
             # Using just SC_ARG_MAX without extra downwards adjustment
             # results in "[Errno 7] Argument list too long" on MacOS.
-            syslimit = os.sysconf('SC_ARG_MAX') - 20000
+            commandLinePrefixAllowance -= 20000
+            syslimit = os.sysconf('SC_ARG_MAX')
             if syslimit == -1:
                 syslimit = 262144 # we could use sys.maxint but we prefer a more robust smaller value
             limit = syslimit - commandLinePrefixAllowance
+            assert limit > 0
     for i in range(len(files)):
         path = pathFunction(files[i])
         size = len(path) + 1
+        assert size < limit
         if chunkSize + size < limit:
             chunkSize += size
         else: