{"record":{"id":"a9caab2d6a5cee4e","repo":"jenkinsci/jenkins","slug":"failed-to-exec-exe-libc-strerror-native-getla","errorCode":null,"errorMessage":"Failed to exec '{exe}' {LIBC.strerror(Native.getLastError())}","messagePattern":"Failed to exec '(.+?)' (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"critical","filePath":"core/src/main/java/hudson/lifecycle/UnixLifecycle.java","lineNumber":85,"sourceCode":"            if (jenkins != null) {\n                jenkins.cleanUp();\n            }\n        } catch (Throwable e) {\n            LOGGER.log(Level.SEVERE, \"Failed to clean up. Restart will continue.\", e);\n        }\n\n        // close all files upon exec, except stdin, stdout, and stderr\n        int sz = LIBC.getdtablesize();\n        for (int i = 3; i < sz; i++) {\n            int flags = LIBC.fcntl(i, F_GETFD);\n            if (flags < 0) continue;\n            LIBC.fcntl(i, F_SETFD, flags | FD_CLOEXEC);\n        }\n\n        // exec to self\n        String exe = args.getFirst();\n        LIBC.execvp(exe, new StringArray(args.toArray(new String[0])));\n        throw new IOException(\"Failed to exec '\" + exe + \"' \" + LIBC.strerror(Native.getLastError()));\n    }\n\n    @Override\n    public void verifyRestartable() throws RestartNotSupportedException {\n        if (!Functions.isGlibcSupported()) {\n            throw new RestartNotSupportedException(\"Restart is not supported on platforms without libc\");\n        }\n\n        // see http://lists.apple.com/archives/cocoa-dev/2005/Oct/msg00836.html and\n        // http://factor-language.blogspot.com/2007/07/execve-returning-enotsup-on-mac-os-x.html\n        // on Mac, execv fails with ENOTSUP if the caller is multi-threaded, resulting in an error like\n        // the one described in http://www.nabble.com/Restarting-hudson-not-working-on-MacOS--to24641779.html\n        //\n        // according to http://www.mail-archive.com/wine-devel@winehq.org/msg66797.html this now works on Snow Leopard\n        if (Platform.isDarwin() && !Platform.isSnowLeopardOrLater())\n            throw new RestartNotSupportedException(\"Restart is not supported on Mac OS X\");\n    }\n","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/jenkinsci/jenkins/blob/2e228ff40b14dbc8b14ffbc6edf0e4383cf744fc/core/src/main/java/hudson/lifecycle/UnixLifecycle.java#L67-L103","documentation":"Thrown immediately after LIBC.execvp() in UnixLifecycle.restart(). execvp only returns on failure (a successful exec replaces the process image), so reaching this line means the exec system call failed. The message includes the executable path and the C-level errno string from Native.getLastError(). This is a hard restart failure — the current process is still alive but the restart did not happen.","triggerScenarios":"UnixLifecycle.restart() builds the argv (args list) from the original launch command, closes all file descriptors >= 3 with FD_CLOEXEC, then calls execvp(exe, argv). If exe does not exist, is not executable, or has a permission/ENOEXEC issue, execvp fails and this IOException is thrown.","commonSituations":"The original java executable or jenkins.war was moved/renamed after Jenkins started; running from a path on a filesystem that has since been unmounted; incorrect exec permissions on the java binary; a misconfigured JAVA_HOME that no longer resolves; running on a read-only filesystem.","solutions":["Check the errno string in the message — ENOENT means the exe path is gone, EACCES means a permission problem","Ensure the java executable and jenkins.war paths used at launch still exist and are executable","Restart Jenkins manually from the correct launch command","Pin the launch script to absolute paths so the exe does not depend on PATH resolution"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"String exe = ProcessHandle.current().info().command().orElse(null);\nif (exe == null || !new File(exe).canExecute()) {\n    throw new IllegalStateException(\"Launch executable not resolvable/executable: \" + exe);\n}","typeGuard":null,"tryCatchPattern":"try {\n    Lifecycle.get().restart();\n} catch (IOException e) {\n    if (e.getMessage().startsWith(\"Failed to exec\")) {\n        // exec failed; parse errno, check exe path, restart manually\n    }\n    throw e;\n}","preventionTips":["Launch Jenkins with absolute paths for java and the war to survive restarts","Do not move/rename the java binary or war after starting Jenkins","On read-only or ephemeral filesystems, avoid the exec-based restart path"],"tags":["lifecycle","unix","restart","exec","native","jni"],"backgroundTag":null,"analyzedSha":"2e228ff40b14dbc8b14ffbc6edf0e4383cf744fc","analyzedAt":"2026-08-14T07:07:15.274Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}