public void restart() throws Exception { // close all files upon exec, except stdin, stdout, and stderr int sz = LIBC.getdtablesize(); for (int i = 3; i < sz; i++) { int flags = LIBC.fcntl(i, F_GETFD); if (flags < 0) continue; LIBC.fcntl(i, F_SETFD, flags | FD_CLOEXEC); } // exec to self String exe = Daemon.getCurrentExecutable(); LIBC.execv(exe, new StringArray(args.toArray(new String[args.size()]))); throw new IOException("Failed to exec '" + exe + "' " + LIBC.strerror(Native.getLastError())); }
@Override public void restart() throws IOException, InterruptedException { Jenkins jenkins = Jenkins.getInstanceOrNull(); // guard against repeated concurrent calls to restart try { if (jenkins != null) { jenkins.cleanUp(); } } catch (Exception e) { LOGGER.log(Level.SEVERE, "Failed to clean up. Restart will continue.", e); } // close all files upon exec, except stdin, stdout, and stderr int sz = LIBC.getdtablesize(); for(int i=3; i<sz; i++) { int flags = LIBC.fcntl(i, F_GETFD); if(flags<0) continue; LIBC.fcntl(i, F_SETFD,flags| FD_CLOEXEC); } // exec to self String exe = args.get(0); LIBC.execvp(exe, new StringArray(args.toArray(new String[args.size()]))); throw new IOException("Failed to exec '"+exe+"' "+LIBC.strerror(Native.getLastError())); }
/** * Run chmod via libc if we can, otherwise fall back to Ant. */ private static void _chmod(File f, int mask) throws IOException { if (Functions.isWindows()) return; // noop try { if(LIBC.chmod(f.getAbsolutePath(),mask)!=0) { throw new IOException("Failed to chmod "+f+" : "+LIBC.strerror(Native.getLastError())); } } catch(NoClassDefFoundError e) { // cf. https://groups.google.com/group/hudson-dev/browse_thread/thread/6d16c3e8ea0dbc9?hl=fr _chmodAnt(f, mask); } catch(UnsatisfiedLinkError e2) { // HUDSON-8155: use Ant's chmod task on non-GNU C systems _chmodAnt(f, mask); } }
/** * Run chmod via libc if we can, otherwise fall back to Ant. */ private static void _chmod(File f, int mask) throws IOException { if (Functions.isWindows()) return; // noop try { if(LIBC.chmod(f.getAbsolutePath(),mask)!=0) { throw new IOException("Failed to chmod "+f+" : "+LIBC.strerror(Native.getLastError())); } } catch(NoClassDefFoundError e) { // cf. https://groups.google.com/group/hudson-dev/browse_thread/thread/6d16c3e8ea0dbc9?hl=fr _chmodAnt(f, mask); } catch(UnsatisfiedLinkError e2) { // HUDSON-8155: use Ant's chmod task on non-GNU C systems _chmodAnt(f, mask); } }
if (r!=0) { r = Native.getLastError(); errmsg = LIBC.strerror(r);
if (r!=0) { r = Native.getLastError(); errmsg = LIBC.strerror(r);
if (r!=0) { r = Native.getLastError(); errmsg = LIBC.strerror(r);
if (err==22/*EINVAL --- but is this really portable?*/) return null; // this means it's not a symlink throw new IOException("Failed to readlink "+link+" error="+ err+" "+ LIBC.strerror(err));
if (err==22/*EINVAL --- but is this really portable?*/) return null; // this means it's not a symlink throw new IOException("Failed to readlink "+link+" error="+ err+" "+ LIBC.strerror(err));
public void restart() throws Exception { // close all files upon exec, except stdin, stdout, and stderr int sz = LIBC.getdtablesize(); for (int i = 3; i < sz; i++) { int flags = LIBC.fcntl(i, F_GETFD); if (flags < 0) continue; LIBC.fcntl(i, F_SETFD, flags | FD_CLOEXEC); } // exec to self String exe = Daemon.getCurrentExecutable(); LIBC.execv(exe, new StringArray(args.toArray(new String[args.size()]))); throw new IOException("Failed to exec '" + exe + "' " + LIBC.strerror(Native.getLastError())); }
@Override public void restart() throws IOException, InterruptedException { Jenkins jenkins = Jenkins.getInstanceOrNull(); // guard against repeated concurrent calls to restart try { if (jenkins != null) { jenkins.cleanUp(); } } catch (Exception e) { LOGGER.log(Level.SEVERE, "Failed to clean up. Restart will continue.", e); } // close all files upon exec, except stdin, stdout, and stderr int sz = LIBC.getdtablesize(); for(int i=3; i<sz; i++) { int flags = LIBC.fcntl(i, F_GETFD); if(flags<0) continue; LIBC.fcntl(i, F_SETFD,flags| FD_CLOEXEC); } // exec to self String exe = args.get(0); LIBC.execvp(exe, new StringArray(args.toArray(new String[args.size()]))); throw new IOException("Failed to exec '"+exe+"' "+LIBC.strerror(Native.getLastError())); }
@Override public void restart() throws IOException, InterruptedException { Hudson h = Hudson.getInstance(); if (h != null) h.cleanUp(); // close all files upon exec, except stdin, stdout, and stderr int sz = LIBC.getdtablesize(); for(int i=3; i<sz; i++) { int flags = LIBC.fcntl(i, F_GETFD); if(flags<0) continue; LIBC.fcntl(i, F_SETFD,flags| FD_CLOEXEC); } // exec to self LIBC.execv( Daemon.getCurrentExecutable(), new StringArray(args.toArray(new String[args.size()]))); throw new IOException("Failed to exec "+LIBC.strerror(Native.getLastError())); }
@Override public void restart() throws IOException, InterruptedException { Hudson h = Hudson.getInstance(); if (h != null) h.cleanUp(); // close all files upon exec, except stdin, stdout, and stderr int sz = LIBC.getdtablesize(); for(int i=3; i<sz; i++) { int flags = LIBC.fcntl(i, F_GETFD); if(flags<0) continue; LIBC.fcntl(i, F_SETFD,flags| FD_CLOEXEC); } // exec to self LIBC.execv( Daemon.getCurrentExecutable(), new StringArray(args.toArray(new String[args.size()]))); throw new IOException("Failed to exec "+LIBC.strerror(Native.getLastError())); }