-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JENKINS-72833] Do not attempt to self-
exec
on systems without `lib…
…c` (#9025)
- Loading branch information
Showing
3 changed files
with
16 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,8 @@ | |
|
||
import com.sun.jna.Native; | ||
import com.sun.jna.StringArray; | ||
import edu.umd.cs.findbugs.annotations.NonNull; | ||
import hudson.Functions; | ||
import hudson.Platform; | ||
import java.io.IOException; | ||
import java.util.List; | ||
|
@@ -50,16 +52,12 @@ | |
* @since 1.304 | ||
*/ | ||
public class UnixLifecycle extends Lifecycle { | ||
|
||
@NonNull | ||
private List<String> args; | ||
private Throwable failedToObtainArgs; | ||
|
||
public UnixLifecycle() throws IOException { | ||
try { | ||
args = JavaVMArguments.current(); | ||
} catch (UnsupportedOperationException | LinkageError e) { | ||
// can't restart / see JENKINS-3875 | ||
failedToObtainArgs = e; | ||
} | ||
public UnixLifecycle() { | ||
args = JavaVMArguments.current(); | ||
} | ||
|
||
@Override | ||
|
@@ -89,6 +87,10 @@ public void restart() throws IOException, InterruptedException { | |
|
||
@Override | ||
public void verifyRestartable() throws RestartNotSupportedException { | ||
if (!Functions.isGlibcSupported()) { | ||
throw new RestartNotSupportedException("Restart is not supported on platforms without libc"); | ||
} | ||
|
||
// see http://lists.apple.com/archives/cocoa-dev/2005/Oct/msg00836.html and | ||
// http://factor-language.blogspot.com/2007/07/execve-returning-enotsup-on-mac-os-x.html | ||
// on Mac, execv fails with ENOTSUP if the caller is multi-threaded, resulting in an error like | ||
|
@@ -97,8 +99,6 @@ public void verifyRestartable() throws RestartNotSupportedException { | |
// according to http://www.mail-archive.com/[email protected]/msg66797.html this now works on Snow Leopard | ||
if (Platform.isDarwin() && !Platform.isSnowLeopardOrLater()) | ||
throw new RestartNotSupportedException("Restart is not supported on Mac OS X"); | ||
if (args == null) | ||
throw new RestartNotSupportedException("Failed to obtain the command line arguments of the process", failedToObtainArgs); | ||
} | ||
|
||
private static final Logger LOGGER = Logger.getLogger(UnixLifecycle.class.getName()); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters