Example usage for java.lang Process toString

List of usage examples for java.lang Process toString

Introduction

In this page you can find the example usage for java.lang Process toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:Main.java

public static void destroy(Process process) {
    // stupid method for getting the pid, but it actually works
    Matcher matcher = PID_PATTERN.matcher(process.toString());
    matcher.find();//  w  w  w .j a va2  s  .  c o  m
    int pid = Integer.parseInt(matcher.group());
    List<Integer> allRelatedPids = getAllRelatedPids(pid);
    for (Integer relatedPid : allRelatedPids) {
        destroyPid(relatedPid);
    }
}

From source file:com.roche.iceboar.runner.ExecutableCommand.java

public Process exec() {
    try {//from   ww  w  . ja v  a 2  s  .  co m
        System.out.println("Try to start: " + getReadable() + "\n");
        Process process = Runtime.getRuntime().exec(cmd);
        System.out.println("Process: " + process.toString());
        return process;
    } catch (IOException e) {
        System.err.println("Failed to execute: " + getReadable());
        throw new IceBoarException(
                "Failed to start a target application. Please try again. See debug view " + "for more details.",
                e);
    }
}

From source file:com.clustercontrol.agent.job.DeleteProcessThread.java

/**
 * ?<BR>/*from w ww. j a v a2  s  .  c o  m*/
 * 
 * ReceiveTopic??????????? ??????
 * 
 */
/*
 * (non-Javadoc)
 * 
 * @see java.lang.Runnable#run()
 */
@Override
public void run() {
    m_log.debug("run start");

    Process process = null;

    //??
    process = RunHistoryUtil.findRunHistory(m_info);

    if (process == null) {
        // ????????
        m_log.warn("run() : process is null");
        RunResultInfo info = new RunResultInfo();
        info.setSessionId(m_info.getSessionId());
        info.setJobunitId(m_info.getJobunitId());
        info.setJobId(m_info.getJobId());
        info.setFacilityId(m_info.getFacilityId());
        info.setCommand(m_info.getCommand());
        info.setCommandType(m_info.getCommandType());
        info.setStopType(m_info.getStopType());
        info.setStatus(RunStatusConstant.ERROR);
        info.setTime(HinemosTime.getDateInstance().getTime());
        info.setEndValue(-1);
        info.setMessage("Internal Error : Ex. Agent restarted or Job already terminated.");
        info.setErrorMessage("");
        // ?
        m_sendQueue.put(info);
        return;
    }

    // ---------------------------
    // -- ?
    // ---------------------------

    // ?
    RunResultInfo info = new RunResultInfo();
    info.setSessionId(m_info.getSessionId());
    info.setJobunitId(m_info.getJobunitId());
    info.setJobId(m_info.getJobId());
    info.setFacilityId(m_info.getFacilityId());
    info.setCommand(m_info.getCommand());
    info.setCommandType(m_info.getCommandType());
    info.setStopType(m_info.getStopType());
    info.setStatus(RunStatusConstant.START);
    info.setTime(HinemosTime.getDateInstance().getTime());

    m_log.info("Process Delete SessionID=" + m_info.getSessionId() + ", JobID=" + m_info.getJobId());

    // ?
    m_sendQueue.put(info);

    //??
    m_log.info("run() : shutdown process : " + process.toString());
    try {
        process.destroy();
        info.setEndValue(process.waitFor());
    } catch (Exception e) {
        m_log.warn("shutdown process : " + e.getMessage());

        // ?
        info.setTime(HinemosTime.getDateInstance().getTime());
        info.setEndValue(-1);
        info.setStatus(RunStatusConstant.ERROR);
        info.setMessage(e.getMessage());
        info.setErrorMessage("");
        m_sendQueue.put(info);
        return;
    }

    // ---------------------------
    // -- ?
    // ---------------------------

    info.setTime(HinemosTime.getDateInstance().getTime());
    info.setStatus(RunStatusConstant.END);
    m_sendQueue.put(info);

    ////?
    RunHistoryUtil.delRunHistory(m_info);

    m_log.debug("run end");
}

From source file:org.apache.falcon.extensions.util.ExtensionProcessBuilderUtils.java

public static Entity createProcessFromTemplate(final String processTemplate, final String extensionName,
        final Properties extensionProperties, final String wfPath, final String wfLibPath)
        throws FalconException {
    if (StringUtils.isBlank(processTemplate) || StringUtils.isBlank(extensionName)
            || extensionProperties == null || StringUtils.isBlank(wfPath)) {
        throw new FalconException("Invalid arguments passed to extension builder");
    }// www  . j  a va 2 s  .  c  om
    org.apache.falcon.entity.v0.process.Process process = bindAttributesInTemplate(processTemplate,
            extensionProperties, extensionName, wfPath, wfLibPath);

    validateGeneratedProcess(process.toString());
    return process;
}

From source file:org.openqa.selenium.server.browserlaunchers.AsyncExecute.java

/**
 * Copied from spawn, but actually returns the Process, instead of void
 * @return the spawned process handle//  w  w  w  .  j  av  a2 s.co  m
 */
public Process asyncSpawn() throws IOException {
    if (!environmentBuilder.isEmpty()) {
        setActualExecuteEnvironment();
    }
    if (workingDirectory != null && !workingDirectory.exists()) {
        throw new BuildException(workingDirectory + " doesn't exist.");
    }
    final Process process = launch(project, getCommandline(), getEnvironment(), workingDirectory,
            useVMLauncher);
    if (Os.isFamily("windows")) {
        AsyncExecute.sleepTight(1000);
    }

    OutputStream dummyOut = new OutputStream() {
        public void write(int b) throws IOException {
        }
    };

    ExecuteStreamHandler streamHandler = new PumpStreamHandler(dummyOut);
    streamHandler.setProcessErrorStream(process.getErrorStream());
    streamHandler.setProcessOutputStream(process.getInputStream());
    streamHandler.start();

    project.log("spawned process " + process.toString(), Project.MSG_VERBOSE);
    return process;
}