Package org.eclipse.cdt.utils.spawner
Class Spawner
- java.lang.Object
-
- java.lang.Process
-
- org.eclipse.cdt.utils.spawner.Spawner
-
public class Spawner extends java.lang.Process
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceSpawner.IChannelstatic classSpawner.UnixChannelstatic classSpawner.WinChannel
-
Constructor Summary
Constructors Modifier Constructor Description protectedSpawner(java.lang.String command)Executes the specified string command in a separate process.protectedSpawner(java.lang.String[] cmdarray)Executes the specified command and arguments in a separate process.protectedSpawner(java.lang.String[] cmdarray, java.lang.String[] envp)Executes the specified command and arguments in a separate process with the specified environment.protectedSpawner(java.lang.String[] cmdarray, java.lang.String[] envp, java.io.File dir)Executes the specified command and arguments in a separate process with the specified environment and working directory.protectedSpawner(java.lang.String[] cmdarray, java.lang.String[] envp, java.io.File dir, PTY pty)Spawner(java.lang.String command, boolean bNoRedirect)protectedSpawner(java.lang.String cmd, java.lang.String[] envp)Executes the specified string command in a separate process with the specified environment.protectedSpawner(java.lang.String command, java.lang.String[] envp, java.io.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 Modifier and Type Method Description voiddestroy()See java.lang.Process#destroy (); Clients are responsible for explicitly closing any streams that they have requested through getErrorStream(), getInputStream() or getOutputStream()voidexec_detached(java.lang.String[] cmdarray, java.lang.String[] envp, java.lang.String dirpath)intexec2(java.lang.String[] cmdarray, java.lang.String[] envp, java.lang.String dir, Spawner.IChannel[] chan, java.lang.String slaveName, int masterFD, boolean console)Native method when executing with a terminal emulation.intexitValue()See java.lang.Process#exitValue ();protected voidfinalize()java.io.InputStreamgetErrorStream()See java.lang.Process#getErrorStream (); The client is responsible for closing the stream explicitly.java.io.InputStreamgetInputStream()See java.lang.Process#getInputStream (); The client is responsible for closing the stream explicitly.java.io.OutputStreamgetOutputStream()See java.lang.Process#getOutputStream (); The client is responsible for closing the stream explicitly.inthangup()intinterrupt()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.intinterruptCTRLC()On Windows, interrupt the spawned program by send it a CTRL-C (even if it's a Cygwin program).booleanisRunning()intkill()intraise(int processID, int sig)Native method to drop a signal on the process with pid.intterminate()intwaitFor()See java.lang.Process#waitFor ();intwaitFor(int processID)Native method to wait(3) for process to terminate.
-
-
-
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)
- If the process this is being raised against was launched by us (the Spawner)
-
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(java.lang.String command, boolean bNoRedirect) throws java.io.IOException- Throws:
java.io.IOException
-
Spawner
protected Spawner(java.lang.String[] cmdarray, java.lang.String[] envp, java.io.File dir) throws java.io.IOExceptionExecutes the specified command and arguments in a separate process with the specified environment and working directory.- Throws:
java.io.IOException
-
Spawner
protected Spawner(java.lang.String[] cmdarray, java.lang.String[] envp, java.io.File dir, PTY pty) throws java.io.IOException- Throws:
java.io.IOException
-
Spawner
protected Spawner(java.lang.String command) throws java.io.IOExceptionExecutes the specified string command in a separate process.- Throws:
java.io.IOException
-
Spawner
protected Spawner(java.lang.String[] cmdarray) throws java.io.IOExceptionExecutes the specified command and arguments in a separate process.- Throws:
java.io.IOException
-
Spawner
protected Spawner(java.lang.String[] cmdarray, java.lang.String[] envp) throws java.io.IOExceptionExecutes the specified command and arguments in a separate process with the specified environment.- Throws:
java.io.IOException
-
Spawner
protected Spawner(java.lang.String cmd, java.lang.String[] envp) throws java.io.IOExceptionExecutes the specified string command in a separate process with the specified environment.- Throws:
java.io.IOException
-
Spawner
protected Spawner(java.lang.String command, java.lang.String[] envp, java.io.File dir) throws java.io.IOExceptionExecutes the specified string command in a separate process with the specified environment and working directory.- Throws:
java.io.IOException
-
-
Method Detail
-
finalize
protected void finalize() throws java.lang.Throwable- Overrides:
finalizein classjava.lang.Object- Throws:
java.lang.Throwable
-
getInputStream
public java.io.InputStream getInputStream()
See java.lang.Process#getInputStream (); The client is responsible for closing the stream explicitly.- Specified by:
getInputStreamin classjava.lang.Process
-
getOutputStream
public java.io.OutputStream getOutputStream()
See java.lang.Process#getOutputStream (); The client is responsible for closing the stream explicitly.- Specified by:
getOutputStreamin classjava.lang.Process
-
getErrorStream
public java.io.InputStream getErrorStream()
See java.lang.Process#getErrorStream (); The client is responsible for closing the stream explicitly.- Specified by:
getErrorStreamin classjava.lang.Process
-
waitFor
public int waitFor() throws java.lang.InterruptedExceptionSee java.lang.Process#waitFor ();- Specified by:
waitForin classjava.lang.Process- Throws:
java.lang.InterruptedException
-
exitValue
public int exitValue()
See java.lang.Process#exitValue ();- Specified by:
exitValuein classjava.lang.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:
destroyin classjava.lang.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(java.lang.String[] cmdarray, java.lang.String[] envp, java.lang.String dirpath) throws java.io.IOException- Throws:
java.io.IOException
-
exec2
public int exec2(java.lang.String[] cmdarray, java.lang.String[] envp, java.lang.String dir, Spawner.IChannel[] chan, java.lang.String slaveName, int masterFD, boolean console) throws java.io.IOExceptionNative method when executing with a terminal emulation.- Throws:
java.io.IOException- Restriction:
- This method is not intended to be referenced by clients.
-
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.- Restriction:
- This method is not intended to be referenced by clients.
-
-