Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] 2 questions re: launch


DerekHi,

I'm launching an external application that does some processing and
either a) creates a file with its results or b) outputs its results to
stdout.

Q1: How do I detect the program has exited, and get its exit code?
Q2: How do I capture its output (preferably in an InputStream)?

My launch code looks like this: (Note for debug purposes, I am using a
console for the external program output)

public ILaunch launch(IProgressMonitor monitor) throws CoreException
{
    ILaunchManager launchManager = DebugPlugin.getDefault()
                .getLaunchManager();
    ILaunchConfigurationType type = launchManager
        .getLaunchConfigurationType(LAUNCH_CONFIG_TYPE);

    String name = launchManager
        .generateUniqueLaunchConfigurationNameFrom(
        launchFile.getName());
    ILaunchConfigurationWorkingCopy workingCopy =
        type.newInstance(null, name);

    workingCopy.setAttribute(ATTR_LOCATION,
        launchFile.getAbsolutePath());
    workingCopy.setAttribute(ATTR_WORKING_DIRECTORY, workingDir
                .getAbsolutePath());
    workingCopy.setAttribute(ATTR_TOOL_ARGUMENTS,
        toolArguments);

    workingCopy.setAttribute(IDebugUIConstants.ATTR_PRIVATE,
        true);

    return workingCopy.launch("run", monitor);
}

Thanks,


Back to the top