# Class RuntimeProcess

java.lang.Object
org.eclipse.core.runtime.PlatformObject
org.eclipse.debug.core.model.RuntimeProcess

All Implemented Interfaces:
  `IAdaptable, IProcess, ITerminate`

public class RuntimeProcess extends PlatformObject implements IProcess
Standard implementation of an `IProcess` that wrappers a system process (`java.lang.Process`).

Clients may subclass this class. Clients that need to replace the implementation of a streams proxy associated with an `IProcess` should subclass this class. Generally clients should not instantiate this class directly, but should instead call `DebugPlugin.newProcess(...)`, which can delegate to an `IProcessFactory` if one is referenced by the associated launch configuration.

Since:
  3.0
See Also:
  - `IProcess`
  - `IProcessFactory`

## Field Summary

### Fields inherited from interface IProcess

`ATTR_CMDLINE, ATTR_PROCESS_ID, ATTR_PROCESS_LABEL, ATTR_PROCESS_TYPE`

## Constructor Summary

Constructors
Constructor
Description
`RuntimeProcess(ILaunch launch, Process process, String name, Map<String,String> attributes)`
Constructs a RuntimeProcess on the given system process with the given name, adding this process to the given launch.

## Method Summary

Modifier and Type
Method
Description
`boolean`
`canTerminate()`
Returns whether this element can be terminated.
`protected IStreamsProxy`
`createStreamsProxy()`
Creates and returns the streams proxy associated with this process.
`protected void`
`fireChangeEvent()`
Fires a change event.
`protected void`
`fireCreationEvent()`
Fires a creation event.
`protected void`
`fireEvent(DebugEvent event)`
Fires the given debug event.
`protected void`
`fireTerminateEvent()`
Fires a terminate event.
`<T> T`
`getAdapter(Class<T> adapter)`
Returns an object which is an instance of the given class associated with this object.
`String`
`getAttribute(String key)`
Returns the value of a client defined attribute.
`int`
`getExitValue()`
Returns the exit value of this process.
`String`
`getLabel()`
Returns a human-readable label for this process.
`ILaunch`
`getLaunch()`
Returns the launch this element originated from.
`IStreamsProxy`
`getStreamsProxy()`
Returns a proxy to the standard input, output, and error streams for this process, or `null` if not supported.
`protected Process`
`getSystemProcess()`
Returns the underlying system process associated with this process.
`boolean`
`isTerminated()`
Returns whether this element is terminated.
`void`
`setAttribute(String key, String value)`
Sets the value of a client defined attribute.
`protected void`
`setLaunch(ILaunch launch)`
Sets the launch this process is contained in
`protected void`
`startStreams()`
Called after notification that this runtime process is created to start the reading of streams.
`void`
`terminate()`
Causes this element to terminate, generating a `TERMINATE` event.
`protected void`
`terminated()`
Notification that the system process associated with this process has terminated.

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### RuntimeProcess

public RuntimeProcess(ILaunch launch, Process process, String name, Map<String,String> attributes)
Constructs a RuntimeProcess on the given system process with the given name, adding this process to the given launch.

Parameters:
  `launch` - the parent launch of this process
  `process` - underlying system process
  `name` - the label used for this process
  `attributes` - map of attributes used to initialize the attributes of this process, or `null` if none

## Method Details

### startStreams

protected void startStreams()
Called after notification that this runtime process is created to start the reading of streams. Must be overridden if a custom `IStreamsProxy` instance is provided by `createStreamsProxy()` that do not extends `StreamsProxy` and does not start the stream reading in any other mean.

Since:
  3.23

### canTerminate

public boolean canTerminate()
Description copied from interface: `ITerminate`
Returns whether this element can be terminated.

Specified by:
  `canTerminate` in interface `ITerminate`
Returns:
  whether this element can be terminated
See Also:
  - `ITerminate.canTerminate()`

### getLabel

public String getLabel()
Description copied from interface: `IProcess`
Returns a human-readable label for this process.

Specified by:
  `getLabel` in interface `IProcess`
Returns:
  a label for this process
See Also:
  - `IProcess.getLabel()`

### setLaunch

protected void setLaunch(ILaunch launch)
Sets the launch this process is contained in

Parameters:
  `launch` - the launch this process is contained in

### getLaunch

public ILaunch getLaunch()
Description copied from interface: `IProcess`
Returns the launch this element originated from.

Specified by:
  `getLaunch` in interface `IProcess`
Returns:
  the launch this process is contained in
See Also:
  - `IProcess.getLaunch()`

### getSystemProcess

protected Process getSystemProcess()
Returns the underlying system process associated with this process.

Returns:
  system process

### isTerminated

public boolean isTerminated()
Description copied from interface: `ITerminate`
Returns whether this element is terminated.

Specified by:
  `isTerminated` in interface `ITerminate`
Returns:
  whether this element is terminated
See Also:
  - `ITerminate.isTerminated()`

### terminate

public void terminate() throws DebugException
Description copied from interface: `ITerminate`
Causes this element to terminate, generating a `TERMINATE` event. Implementations may be blocking or non-blocking.

Specified by:
  `terminate` in interface `ITerminate`
Throws:
  `DebugException` - on failure. Reasons include:
  - TARGET_REQUEST_FAILED - The request failed in the target
  - NOT_SUPPORTED - The capability is not supported by the target
See Also:
  - `ITerminate.terminate()`

### terminated

protected void terminated()
Notification that the system process associated with this process has terminated.

### getStreamsProxy

public IStreamsProxy getStreamsProxy()
Description copied from interface: `IProcess`
Returns a proxy to the standard input, output, and error streams for this process, or `null` if not supported.

Specified by:
  `getStreamsProxy` in interface `IProcess`
Returns:
  a streams proxy, or `null` if not supported
See Also:
  - `IProcess.getStreamsProxy()`

### createStreamsProxy

protected IStreamsProxy createStreamsProxy()
Creates and returns the streams proxy associated with this process.

Returns:
  streams proxy

### fireCreationEvent

protected void fireCreationEvent()
Fires a creation event.

### fireEvent

protected void fireEvent(DebugEvent event)
Fires the given debug event.

Parameters:
  `event` - debug event to fire

### fireTerminateEvent

protected void fireTerminateEvent()
Fires a terminate event.

### fireChangeEvent

protected void fireChangeEvent()
Fires a change event.

### setAttribute

public void setAttribute(String key, String value)
Description copied from interface: `IProcess`
Sets the value of a client defined attribute.

Specified by:
  `setAttribute` in interface `IProcess`
Parameters:
  `key` - the attribute key
  `value` - the attribute value
See Also:
  - `IProcess.setAttribute(String, String)`

### getAttribute

public String getAttribute(String key)
Description copied from interface: `IProcess`
Returns the value of a client defined attribute.

Specified by:
  `getAttribute` in interface `IProcess`
Parameters:
  `key` - the attribute key
Returns:
  value the String attribute value, or `null` if undefined
See Also:
  - `IProcess.getAttribute(String)`

### getAdapter

public <T> T getAdapter(Class<T> adapter)
Description copied from class: `PlatformObject`
Returns an object which is an instance of the given class associated with this object. Returns `null` if no such object can be found.

This implementation of the method declared by `IAdaptable` passes the request along to the platform's adapter manager; roughly `Platform.getAdapterManager().getAdapter(this, adapter)`. Subclasses may override this method (however, if they do so, they should invoke the method on their superclass to ensure that the Platform's adapter manager is consulted).

Specified by:
  `getAdapter` in interface `IAdaptable`
Overrides:
  `getAdapter` in class `PlatformObject`
Type Parameters:
  `T` - the class type
Parameters:
  `adapter` - the class to adapt to
Returns:
  the adapted object or `null`
See Also:
  - `IAdaptable.getAdapter(Class)`

### getExitValue

public int getExitValue() throws DebugException
Description copied from interface: `IProcess`
Returns the exit value of this process. Conventionally, 0 indicates normal termination.

Specified by:
  `getExitValue` in interface `IProcess`
Returns:
  the exit value of this process
Throws:
  `DebugException` - if this process has not yet terminated
See Also:
  - `IProcess.getExitValue()`