Process CLASS

The class to represent an OS process.

Parent Class

All Members


TypeNameSignature
constructorProcesspublic Process(string, string[], System.ProcessConfig)
method Screatepublic static Process create(string, string[])
methodgetArgspublic String[] getArgs()
method SgetCurrentpublic static Process getCurrent()
methodgetEnvArgpublic String getEnvArg(string)
methodgetErrorStreampublic Stream getErrorStream()
methodgetExitCodepublic int getExitCode()
methodgetNamepublic String getName()
methodgetReadStreampublic Stream getReadStream()
methodgetWriteStreampublic Stream getWriteStream()
methodisAlivepublic bool isAlive()
methodkillpublic int kill()
methodstartpublic void start()
methodwaitpublic int wait()
methodwaitpublic bool wait(int)

Constructors


public Process(string name, string[] args, ProcessConfig config)

Create a process with specific settings.

Parameters

  • name The (path and) name of executable. A simple name will be resolved to an executable against the executable paths of OS (for example, the PATH environment variable on Windows and Linux). A path-like name will be resolved against the file system.
  • args The argument array to pass along to the process. Each element will be treated as a single argument, even if it contains space characters.
  • config The configuration object for this process.

Methods


public static Process create(string name, string[] args)

A facade to create a process with default settings.

Parameters

  • name The (path and) name of executable. A simple name will be resolved to an executable against the executable paths of OS (for example, the PATH environment variable on Windows and Linux). A path-like name will be resolved against the file system.
  • args The argument array to pass along to the process. Each element will be treated as a single argument, even if it contains space characters.

Returns

  • An instance representing the process, which has yet to start. One must call start to kick it off.

public String[] getArgs()

Get the arguments of this process.

Returns

  • The exactly same argumenst set by the constructor.

public static Process getCurrent()

Get the Process object for the currently running process.

Since the returned object represents the current process (a JVM instance on which Julian engine is running), most methods that have modifying behavior are not allowed to call.

Required Policies

  • System.Environment/read

Returns

  • An instance representing the current process.

public String getEnvArg(string name)

Get the environment variable. This method will only work against the current process object, otherwise it throws.

Required Policies

  • System.Environment/read

Parameters

  • name The environment variable's name

Returns

  • The environment variable with the specified name. Null if not existing.

public Stream getErrorStream()

Get a stream to read from this process's standard error. This stream is backed by an OS pipeline. Note, however, if the process was started with inherited IO, or an explicitly set ErrorStream, then one cannot read from it programmatically and thus this method returns null.

Returns


public int getExitCode()

Get the exit code. Result is undefined if the process is not terminated yet.

Required Policies

  • System.Process/control

Returns

  • If the process has finished, the exit code as returned by that process. If the process has not finished, the status code is undefined.

public String getName()

Get the name of this process.

Returns

  • The exactly same name set by the constructor.

public Stream getReadStream()

Get a stream to read from this process. This stream is backed by an OS pipeline. Note, however, if the process was started with inherited IO, or an explicitly set OutputStream, then one cannot read from it programmatically and thus this method returns null.

Returns


public Stream getWriteStream()

Get a stream to write to this process. This stream is backed by an OS pipeline. Note, however, if the process was started with inherited IO, or an explicitly set InputStream, then one cannot write to it programmatically and thus this method returns null.

Returns


public bool isAlive()

Check if the process is alive. This method will return true only before start(), or after either wait() or kill() is called.

Returns

  • True if the process is still running.

public int kill()

Kill the process.

Required Policies

  • System.Process/control

Returns

  • The exit code of the process upon its completion.

Throws


public void start()

Start the process. A process can only be started once.

Required Policies

  • System.Process/control

Throws


public int wait()

Wait for the process to finish.

Required Policies

  • System.Process/wait

Returns

  • The exit code of the process upon its completion.

public bool wait(int millisec)

Wait, for only specified milliseconds, for the process to finish.

Required Policies

  • System.Process/wait

Parameters

  • millisec The duration, in millisec, to wait for the process to finish.

Returns

  • True if the process ran to the end within the specified waiting duration.