up: SYS     index Zimbu documentation

CLASS SYS.Process @public

summary

     

Class for handling processes.

NEW(cmd) @public  Create a Process to run cmd without arguments
NEW(cmd, arglist) @public  Create a Process to run cmd with arguments arglist. Otherwise just like NEW(cmd).
$setIO(flags) SYS.Process @public  Specify what IO of the process will be used.
$start() SYS.Process @public  Start the process.
$didStart() bool @public  Return TRUE if start() has been called.
$isRunning() bool @public  Check if the process is running.
$didExitNormally() bool @public  Return TRUE only if the process was executed and exited normally.
$getExitValue() int @public  Get the exit value of the process.
$wait() status @public  Wait until the process has exited.
$wait(timeout) status @public  Wait until the process has exited up to timeout usec.
$abort() SYS.Process @public  Abort the process. Tries to make the process exit cleanly by sending it Signal.int. If that doesn't work then it is killed with Signal.kill signal.
$setAbortTimeout(timeout) SYS.Process @public  Set the time for abort() to wait for a clean exit to timeout usec.
$interrupt() SYS.Process @public  Interrupt the process.
$kill() SYS.Process @public  Abort the process.
$signal(sig) SYS.Process @public  Send signal sig to the process.
$readFrom(fname) SYS.Process @public  Set the file to be used for stdin of the process to fname.
$writeTo(fname) SYS.Process @public  Set the file to be used for stdout of the process to fname.
$writeErrorsTo(fname) SYS.Process @public  Set the file to be used for stderr of the process to fname.
$writeErrorsToOut(yes) SYS.Process @public  Set wether stderr of the process is written to the same file as specified with writeTo().
$read() string @public  Read all of stdout from the process.
$read(timeout) string @public  Read all of stdout from the process.
$write() SYS.Process @public  Write to stdin of the process.
$write(timeout) SYS.Process @public  Write to stdin of the process.
 

members (alphabetically)

     

PROC NEW(string cmd) @public

     

Create a Process to run cmd without arguments

When cmd contains a "/" it is used as-is. Otherwise $PATH is used to locate the command. See the execvp() man page for details.

PROC NEW(string cmd, list<string> arglist) @public

     

Create a Process to run cmd with arguments arglist. Otherwise just like NEW(cmd).

FUNC $abort() SYS.Process @public

     

Abort the process. Tries to make the process exit cleanly by sending it Signal.int. If that doesn't work then it is killed with Signal.kill signal.

Use setAbortTimeout() to set the time to wait for a clean exit. Default is one second.

Can only be used when process has been started and didn't exit yet.

Returns the object.

FUNC $didExitNormally() bool @public

     

Return TRUE only if the process was executed and exited normally.

FUNC $didStart() bool @public

     

Return TRUE if start() has been called.

FUNC $getExitValue() int @public

     

Get the exit value of the process.

Only to be invoked when didExitNormally() returns TRUE.

FUNC $interrupt() SYS.Process @public

     

Interrupt the process.

Sends Signal.int (signal 2, SIGINT), to the process to make it exit cleanly. The process may intercept the signal and not exit.

Can only be used when process has been started and didn't exit yet.

Returns the object.

FUNC $isRunning() bool @public

     

Check if the process is running.

Returns FALSE if the process didn't start yet and when it exited.

FUNC $kill() SYS.Process @public

     

Abort the process.

Sends Signal.kill (signal 9, SIGKILL), to the process to kill it. The process can't intercept this, use with care.

Can only be used when process has been started and didn't exit yet.

Returns the object.

FUNC $read() string @public

     

Read all of stdout from the process.

Will block until the process exits. Must not be called before the process is started. Returns an empty string when the process already exited.

NOT IMPLEMENTED YET

FUNC $read(int timeout) string @public

     

Read all of stdout from the process.

Will block until the process exits or timeout usec has passed. Must not be called before the process is started. Returns an empty string when the process already exited.

NOT IMPLEMENTED YET

FUNC $readFrom(string fname) SYS.Process @public

     

Set the file to be used for stdin of the process to fname.

This works like "cmd < fname" in the shell. Must be invoked before the process is started.

Returns the object.

FUNC $setAbortTimeout(int timeout) SYS.Process @public

     

Set the time for abort() to wait for a clean exit to timeout usec.

Returns the object.

FUNC $setIO(SYS.IOFlags flags) SYS.Process @public

     

Specify what IO of the process will be used.

Returns the object.

FUNC $signal(SYS.Signal sig) SYS.Process @public

     

Send signal sig to the process.

Returns the object.

Can only be used when process has been started and didn't exit yet.

NOT IMPLEMENTED YET

FUNC $start() SYS.Process @public

     

Start the process.

Can be used only once, a process can't be restarted.

Returns the object.

FUNC $wait() status @public

     

Wait until the process has exited.

FUNC $wait(int timeout) status @public

     

Wait until the process has exited up to timeout usec.

Returns OK if the process has exited, FAIL if timed out.

FUNC $write() SYS.Process @public

     

Write to stdin of the process.

May block until the process has read the input. Must not be called before the process is started or after the process exited.

Returns the object.

NOT IMPLEMENTED YET

FUNC $write(int timeout) SYS.Process @public

     

Write to stdin of the process.

May block until the process has read the input up to timeout usec. Must not be called before the process is started or after the process exited.

Returns the object.

NOT IMPLEMENTED YET

FUNC $writeErrorsTo(string fname) SYS.Process @public

     

Set the file to be used for stderr of the process to fname.

This works like "cmd >& fname" in the shell. If fname exists it is overwritten. Must be invoked before the process is started.

Returns the object.

FUNC $writeErrorsToOut(bool yes) SYS.Process @public

     

Set wether stderr of the process is written to the same file as specified with writeTo().

Must be invoked before the process is started.

Returns the object.

FUNC $writeTo(string fname) SYS.Process @public

     

Set the file to be used for stdout of the process to fname.

This works like "cmd > fname" in the shell. If fname exists it is overwritten. Must be invoked before the process is started.

Returns the object.

license

      Copyright 2010 Bram Moolenaar All Rights Reserved.

      Licensed under the Apache License, Version 2.0. See the LICENSE file or obtain a copy at: http://www.apache.org/licenses/LICENSE-2.0