system.process - Palamecia/mint GitHub Wiki
Module
load system.process
This module provides classes and functions to manage external processes.
Packages
Classes
System.Process
This class is used to start external programs and to communicate with them.
This type is not copyable
Public members
Modifiers | Member | Description |
---|---|---|
@ const |
current | Returns an instance of System.Process managing the current process. |
const |
delete | Cleans up the process instance. |
const |
exec | Starts the configured process and blocks until the process has finished. Retu... |
const |
getArguments | Returns a list containing the command line arguments of the managed process. |
const |
getCommand | Returns the command (application path) of the managed process. |
const |
getEnvironment | Returns an hash containing the environment variables of the managed process (... |
const |
getExitCode | Returns the exit code returned by the la execution of the process. A return c... |
const |
getExitStatus | Returns false if the last execution was terminated abnormally; otherwise re... |
const |
getPid | Returns the PID of the managed process or none if the process has no PID (i... |
const |
getWorkingDirectory | Returns the working directory assigned to the managed process as an instance ... |
const |
isRunning | Returns true if the managed process is running; otherwise returns false . ... |
const |
kill | Kills the managed process, causing it to exit immediately. Returns true if ... |
@ const |
list | Returns an iterator on each running process PID as a number. The returned val... |
const |
new | Creates a new object managing the process identified by ident . If the ide ... |
const |
read | Reads all the data on the standard output of the called process. |
const |
readError | Reads all the data on the error output of the called process. |
const |
setEnvironment | Sets the environment variables to environment . The process will be started ... |
const |
setWorkingDirectory | Sets the working directory to workingDirectory . The process will be started... |
const |
start | Starts the configured process and return immediately. Returns true if the p... |
const |
terminate | Attempts to terminate the managed process. The process may not exit as a resu... |
const |
wait | Blocks until the process has finished. Returns true if the process was corr... |
const |
write | Writes the content of data to the standard input of the called process. If ... |
Private members
Modifiers | Member | Description |
---|---|---|
final |
args | Internal arguments list. |
const |
clone | Disable object copy. |
final |
command | Internal commande. |
final |
environment | Internal environment. |
final |
exitCode | Internal last exit code. |
final |
exitStatus | Internal last exit status. |
@ |
g_current | Global instance of current process. |
@ |
g_lib | Global library handle. |
final |
handle | Internal process handle. |
final |
pipes | Internal pipes for communication between processes. |
final |
workingDirectory | Internal working directory. |
Functions
Descriptions
System.Process.args
[]
Internal arguments list.
System.Process.clone
none
Disable object copy.
System.Process.command
''
Internal commande.
System.Process.current
def ()
Returns an instance of System.Process managing the current process.
System.Process.delete
def (self)
Cleans up the process instance.
System.Process.environment
none
Internal environment.
System.Process.exec
def (self, ...)
Starts the configured process and blocks until the process has
finished. Returns true
if the process was correctly started and
executed; otherwise returns false
. The exit code can then be
retrived by the function getExitCode and the messages and errors
by the read and readError functions. The started process
can be configured using the setEnvironment and
setWorkingDirectory functions. The parameters passed to this
method are used as command line arguments for the started process.
An instance of Exception.SystemError is raised on error.
System.Process.exitCode
0
Internal last exit code.
System.Process.exitStatus
true
Internal last exit status.
System.Process.g_current
none
Global instance of current process.
System.Process.g_lib
lib ('libmint-system')
Global library handle.
System.Process.getArguments
def (const self)
Returns a list containing the command line arguments of the managed process.
System.Process.getCommand
def (const self)
Returns the command (application path) of the managed process.
System.Process.getEnvironment
def (const self)
Returns an hash containing the environment variables of the managed process (name to value).
System.Process.getExitCode
def (const self)
Returns the exit code returned by the la execution of the process.
A return code of 0
is returned for process that were never
executed.
System.Process.getExitStatus
def (const self)
Returns false
if the last execution was terminated abnormally;
otherwise returns true
. A return value of true
can either mean
that the execution was successfull, never started or not terminated.
System.Process.getPid
def (const self)
Returns the PID of the managed process or none
if the process has
no PID (i.e. is not running).
System.Process.getWorkingDirectory
def (const self)
Returns the working directory assigned to the managed process as an instance of System.Directory.
System.Process.handle
none
Internal process handle.
System.Process.isRunning
def (const self)
Returns true
if the managed process is running; otherwise returns
false
. The process is not running if it was not correctly started
or has finished. The getExitStatus and getExitCode can
used to get extra informations on non running processes.
System.Process.kill
def (self)
Kills the managed process, causing it to exit immediately. Returns
true
if the request was successfully sent to the process; otherwise
returns false
. The process must be running.
An instance of Exception.SystemError is raised on error.
System.Process.list
def ()
Returns an iterator on each running process PID as a number. The returned values can be used as the parameter to create an instance of System.Process to manage the associated process.
System.Process.new
def (self, ident)
Creates a new object managing the process identified by ident
.
If the ident
parameter is an instance of System.Process, the given
value is returned by the function as the new instance.
If the ident
parameter is a number, this value is used as a process
identifier (PID) to find the associated process. The process must be
already runing.
If ident
rovides a toProcess
method, this method is used to create
the returned value; otherwise desc
is cast to string to get a path
to an application. The process must then be started using the exec
or start method.
System.Process.pipes
[]
Internal pipes for communication between processes.
System.Process.read
def (self)
Reads all the data on the standard output of the called process.
System.Process.readError
def (self)
Reads all the data on the error output of the called process.
System.Process.setEnvironment
def (self, environment)
Sets the environment variables to environment
. The process will be
started using this environment. The parameter must be an hash (name
to value) and the function must be called before start or
exec. By default, the environment is copied from the current
process.
System.Process.setWorkingDirectory
def (self, workingDirectory)
Sets the working directory to workingDirectory
. The process will be
started in this directory. This function must be called before
start or exec. By default, the working directory is
copied from the current process.
System.Process.start
def (self, ...)
Starts the configured process and return immediately. Returns true
if the process was correctly started; otherwise returns false
. On
success, the wait function can be used to wait until the process
has finished. The started process can be configured using the
setEnvironment and setWorkingDirectory functions. The
parameters passed to this method are used as command line arguments
for the started process.
An instance of Exception.SystemError is raised on error.
System.Process.terminate
def (self)
Attempts to terminate the managed process. The process may not exit
as a result of calling this function (it is given the chance to
prompt the user for any unsaved files, etc). Returns true
if the
request was successfully sent to the process; otherwise returns
false
. The process must be running.
An instance of Exception.SystemError is raised on error.
System.Process.wait
def (self)
Blocks until the process has finished. Returns true
if the process
was correctly executed; otherwise returns false
. The exit code can
then be retrived by the function getExitCode and the messages
and errors by the read and readError functions.
System.Process.workingDirectory
null
Internal working directory.
System.Process.write
def (self, data)
Writes the content of data
to the standard input of the called
process. If the process is not running, the data will be sent once
started.
System.exec
def (command)
Executes the commande line command
as if passed to a terminal. Returns
the exit code of the command.
System.getpid
def ()
Returns the PID of the current process.