Skip to content

Commit e0a55ea

Browse files
chironttSougandhS
authored andcommitted
1 parent 093343f commit e0a55ea

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/ClasspathShortener.java

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2018, 2023 Cedric Chabanois and others.
2+
* Copyright (c) 2018, 2025 Cedric Chabanois and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -11,6 +11,7 @@
1111
* Contributors:
1212
* Cedric Chabanois ([email protected]) - Launching command line exceeds the process creation command limit on *nix - https://bugs.eclipse.org/bugs/show_bug.cgi?id=385738
1313
* IBM Corporation - Launching command line exceeds the process creation command limit on Windows - https://bugs.eclipse.org/bugs/show_bug.cgi?id=327193
14+
* Tue Ton - support for FreeBSD
1415
*******************************************************************************/
1516
package org.eclipse.jdt.internal.launching;
1617

@@ -54,9 +55,11 @@
5455
*/
5556
public class ClasspathShortener implements IProcessTempFileCreator {
5657
private static final String CLASSPATH_ENV_VAR_PREFIX = "CLASSPATH="; //$NON-NLS-1$
58+
public static final int ARG_MAX_FREEBSD = 2097152;
5759
public static final int ARG_MAX_LINUX = 2097152;
5860
public static final int ARG_MAX_WINDOWS = 32767;
5961
public static final int ARG_MAX_MACOS = 262144;
62+
public static final int MAX_ARG_STRLEN_FREEBSD = 131072;
6063
public static final int MAX_ARG_STRLEN_LINUX = 131072;
6164
private final String os;
6265
private final String javaVersion;
@@ -261,6 +264,9 @@ protected int getMaxCommandLineLength() {
261264
// POSIX suggests to subtract 2048 additionally so that the process may safely modify its environment.
262265
// see https://www.in-ulm.de/~mascheck/various/argmax/
263266
switch (os) {
267+
case Platform.OS_FREEBSD:
268+
// ARG_MAX will be 1/4 of the stack size. 2097152 by default
269+
return ARG_MAX_FREEBSD - getEnvironmentLength() - 2048;
264270
case Platform.OS_LINUX:
265271
// ARG_MAX will be 1/4 of the stack size. 2097152 by default
266272
return ARG_MAX_LINUX - getEnvironmentLength() - 2048;
@@ -277,6 +283,11 @@ protected int getMaxCommandLineLength() {
277283
}
278284

279285
protected int getMaxArgLength() {
286+
if (os.equals(Platform.OS_FREEBSD)) {
287+
// On FreeBSD, MAX_ARG_STRLEN is the maximum length of a command line argument (or environment variable).
288+
// Its value cannot be changed without recompiling the kernel.
289+
return MAX_ARG_STRLEN_FREEBSD - 2048;
290+
}
280291
if (os.equals(Platform.OS_LINUX)) {
281292
// On Linux, MAX_ARG_STRLEN (kernel >= 2.6.23) is the maximum length of a command line argument (or environment variable). Its value
282293
// cannot be changed without recompiling the kernel.

0 commit comments

Comments
 (0)