org.eclipse.cdt.utils.spawner

## Class Spawner

- java.lang.Object
- - java.lang.Process
  - - org.eclipse.cdt.utils.spawner.Spawner

    public class Spawner
    extends Process

### Field Summary

Fields
`int` `CTRLC` A fabricated signal number for use on Windows only.
`int` `HUP`
`int` `INT` On Windows, what this does is far from easy to explain.
`int` `KILL`
`int` `NOOP`
`int` `TERM`

### Constructor Summary

Constructors
`protected` `Spawner(String command)` Executes the specified string command in a separate process.
`protected` `Spawner(String[] cmdarray)` Executes the specified command and arguments in a separate process.
`protected` `Spawner(String[] cmdarray, String[] envp)` Executes the specified command and arguments in a separate process with the specified environment.
`protected` `Spawner(String[] cmdarray, String[] envp, File dir)` Executes the specified command and arguments in a separate process with the specified environment and working directory.
`protected` `Spawner(String[] cmdarray, String[] envp, File dir, PTY pty)`
`` `Spawner(String command, boolean bNoRedirect)`
`protected` `Spawner(String cmd, String[] envp)` Executes the specified string command in a separate process with the specified environment.
`protected` `Spawner(String command, String[] envp, File dir)` Executes the specified string command in a separate process with the specified environment and working directory.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `destroy()` See java.lang.Process#destroy (); Clients are responsible for explicitly closing any streams that they have requested through getErrorStream(), getInputStream() or getOutputStream()
`void` `exec_detached(String[] cmdarray, String[] envp, String dirpath)`
`int` `exec2(String[] cmdarray, String[] envp, String dir, int[] chan, String slaveName, int masterFD, boolean console)` Native method when executing with a terminal emulation.
`int` `exitValue()` See java.lang.Process#exitValue ();
`protected void` `finalize()`
`InputStream` `getErrorStream()` See java.lang.Process#getErrorStream (); The client is responsible for closing the stream explicitly.
`InputStream` `getInputStream()` See java.lang.Process#getInputStream (); The client is responsible for closing the stream explicitly.
`OutputStream` `getOutputStream()` See java.lang.Process#getOutputStream (); The client is responsible for closing the stream explicitly.
`int` `hangup()`
`int` `interrupt()` On Windows, interrupt the spawned program by using Cygwin's utility 'kill -SIGINT' if it's a Cgywin program, otherwise send it a CTRL-C.
`int` `interruptCTRLC()` On Windows, interrupt the spawned program by send it a CTRL-C (even if it's a Cygwin program).
`boolean` `isRunning()`
`int` `kill()`
`int` `raise(int processID, int sig)` Native method to drop a signal on the process with pid.
`int` `terminate()`
`int` `waitFor()` See java.lang.Process#waitFor ();
`int` `waitFor(int processID)` Native method to wait(3) for process to terminate.

### Methods inherited from class java.lang.Process

`destroyForcibly, isAlive, waitFor`

### Methods inherited from class java.lang.Object

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

### Field Detail

#### NOOP

    public int NOOP

#### HUP

    public int HUP

#### KILL

    public int KILL

#### TERM

    public int TERM

#### INT

    public int INT

On Windows, what this does is far from easy to explain. Some of the logic is in the JNI code, some in the spawner.exe code.

- If the process this is being raised against was launched by us (the Spawner)
  - If the process is a cygwin program (has the cygwin1.dll loaded), then issue a 'kill -SIGINT'. If the 'kill' utility isn't available, send the process a CTRL-C
  - If the process is not a cygwin program, send the process a CTRL-C
- If the process this is being raised against was not launched by us, use DebugBreakProcess to interrupt it (sending a CTRL-C is easy only if we share a console with the target process)

On non-Windows, raising this just raises a POSIX SIGINT

#### CTRLC

    public int CTRLC

A fabricated signal number for use on Windows only. Tells the starter program to send a CTRL-C regardless of whether the process is a Cygwin one or not.

Since:
  5.2

### Constructor Detail

#### Spawner

    public Spawner(String command,
                   boolean bNoRedirect)
            throws IOException

Throws:
  `IOException`

#### Spawner

    protected Spawner(String[] cmdarray,
                      String[] envp,
                      File dir)
               throws IOException

Executes the specified command and arguments in a separate process with the specified environment and working directory.

Throws:
  `IOException`

#### Spawner

    protected Spawner(String[] cmdarray,
                      String[] envp,
                      File dir,
                      PTY pty)
               throws IOException

Throws:
  `IOException`

#### Spawner

    protected Spawner(String command)
               throws IOException

Executes the specified string command in a separate process.

Throws:
  `IOException`

#### Spawner

    protected Spawner(String[] cmdarray)
               throws IOException

Executes the specified command and arguments in a separate process.

Throws:
  `IOException`

#### Spawner

    protected Spawner(String[] cmdarray,
                      String[] envp)
               throws IOException

Executes the specified command and arguments in a separate process with the specified environment.

Throws:
  `IOException`

#### Spawner

    protected Spawner(String cmd,
                      String[] envp)
               throws IOException

Executes the specified string command in a separate process with the specified environment.

Throws:
  `IOException`

#### Spawner

    protected Spawner(String command,
                      String[] envp,
                      File dir)
               throws IOException

Executes the specified string command in a separate process with the specified environment and working directory.

Throws:
  `IOException`

### Method Detail

#### finalize

    protected void finalize()
                     throws Throwable

Overrides:
  `finalize` in class `Object`
Throws:
  `Throwable`

#### getInputStream

    public InputStream getInputStream()

See java.lang.Process#getInputStream (); The client is responsible for closing the stream explicitly.

Specified by:
  `getInputStream` in class `Process`

#### getOutputStream

    public OutputStream getOutputStream()

See java.lang.Process#getOutputStream (); The client is responsible for closing the stream explicitly.

Specified by:
  `getOutputStream` in class `Process`

#### getErrorStream

    public InputStream getErrorStream()

See java.lang.Process#getErrorStream (); The client is responsible for closing the stream explicitly.

Specified by:
  `getErrorStream` in class `Process`

#### waitFor

    public int waitFor()
                throws InterruptedException

See java.lang.Process#waitFor ();

Specified by:
  `waitFor` in class `Process`
Throws:
  `InterruptedException`

#### exitValue

    public int exitValue()

See java.lang.Process#exitValue ();

Specified by:
  `exitValue` in class `Process`

#### destroy

    public void destroy()

See java.lang.Process#destroy (); Clients are responsible for explicitly closing any streams that they have requested through getErrorStream(), getInputStream() or getOutputStream()

Specified by:
  `destroy` in class `Process`

#### interrupt

    public int interrupt()

On Windows, interrupt the spawned program by using Cygwin's utility 'kill -SIGINT' if it's a Cgywin program, otherwise send it a CTRL-C. If Cygwin's 'kill' command is not available, send a CTRL-C. On linux, interrupt it by raising a SIGINT.

#### interruptCTRLC

    public int interruptCTRLC()

On Windows, interrupt the spawned program by send it a CTRL-C (even if it's a Cygwin program). On linux, interrupt it by raising a SIGINT.

Since:
  5.2

#### hangup

    public int hangup()

#### kill

    public int kill()

#### terminate

    public int terminate()

#### isRunning

    public boolean isRunning()

#### exec_detached

    public void exec_detached(String[] cmdarray,
                              String[] envp,
                              String dirpath)
                       throws IOException

Throws:
  `IOException`

#### exec2

    public int exec2(String[] cmdarray,
                     String[] envp,
                     String dir,
                     int[] chan,
                     String slaveName,
                     int masterFD,
                     boolean console)
              throws IOException

Native method when executing with a terminal emulation.

Throws:
  `IOException`

#### raise

    public int raise(int processID,
                     int sig)

Native method to drop a signal on the process with pid.

#### waitFor

    public int waitFor(int processID)

Native method to wait(3) for process to terminate.