Package org.jvnet.winp

Examples of org.jvnet.winp.WinProcess


  }

  private void shutdown() {
    StreamGobbler.shuttingDown();
    if (windows()) {
      new WinProcess(this.nginxProc).killRecursively();
    } else {
      this.nginxProc.destroy(); // send SIGTERM
    }
    for (PluginConfig p : this.plugins.values()) {
      p.shutDown();
View Full Code Here


      if (windows()) Thread.sleep(1000); // XXX unknown race condition
    } catch (Throwable t) {
      System.err.println("Nginx restart time out plugin =" + pluginId);
      this.plugins.remove(pluginId);
      if (windows()) {
        new WinProcess(proc).killRecursively();
      } else {
        proc.destroy(); // send SIGTERM
      }
      throw new NginxRestartFailedException("nginx restart failed.\n" + "url=" + url + "\n" + "message=" + t.getMessage());
    }  
View Full Code Here

    }

    void shutDown() {
      if (this.isStarted()) {
        if (windowsStatic()) {
          new WinProcess(this.proc).killRecursively();
        } else {
          this.proc.destroy(); // send SIGTERM
        }
      }
    }
View Full Code Here

            }
        }

        @Override
        public OSProcess get(Process proc) {
            return get(new WinProcess(proc).getPid());
        }
View Full Code Here

        // workaround for Windows issue when stopping a process. Use
        // an external library that does a better job stopping
        // processes than Process.destroy()
        if (System.getProperty("os.name").startsWith("Windows")) {
            WinProcess wp = new WinProcess(proc);
            wp.killRecursively();
        } else {
            proc.destroy();
        }
    }
View Full Code Here

* Test program.
* @author Kohsuke Kawaguchi
*/
public class Main {
    public static void main(String[] args) {
        WinProcess p = new WinProcess(Integer.parseInt(args[0]));
        p.killRecursively();
        // p.setPriority(Priority.BELOW_NORMAL);
    }
View Full Code Here

        System.out.println("Failed to get command lines for " + failed + " of " + total + " processes");
    }

    @Test(expected = WinpException.class)
    public void testErrorHandling() {
        new WinProcess(0).getEnvironmentVariables();
    }
View Full Code Here

        ProcessBuilder pb = new ProcessBuilder("notepad");
        pb.environment().put("TEST", "foobar");
        Process p = pb.start();
        Thread.sleep(100); // Try to give the process a little time to start or getting the command line fails randomly

        WinProcess wp = new WinProcess(p);
        System.out.println("pid=" + wp.getPid());

        System.out.println(wp.getCommandLine());
        assertTrue(wp.getCommandLine().contains("notepad"));

        System.out.println(wp.getEnvironmentVariables());
        assertEquals("foobar", wp.getEnvironmentVariables().get("TEST"));

        Thread.sleep(100);
        wp.killRecursively();
    }
View Full Code Here

public class Main2 {
    public static void main(String[] args) throws Exception {
        ProcessBuilder pb = new ProcessBuilder(new String[]{"notepad"});
        Process p = pb.start();
        Thread.sleep(3000);
        new WinProcess(p).killRecursively();
    }
View Full Code Here

/**
* @author Kohsuke Kawaguchi
*/
public class Main3 {
    public static void main(String[] args) {
        WinProcess p = new WinProcess(1572);
        System.out.println(p.getCommandLine());
        System.out.println(p.getEnvironmentVariables());
    }
View Full Code Here

TOP

Related Classes of org.jvnet.winp.WinProcess

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.