| Process |
|
typedict |
| |
A
Process
provides a way to execute a process and interact with its inputs and outputs.
The fields in a
Process
are:
| alive |
An
int
that starts or stops the process when its value is set to non-zero or zero,
respectively.
| | command |
A
String
or an
Array
of strings that completely describes the process.
When
command
is an array the first element is the executable and the remaining elements
are arguments that are passed to the executable,
otherwise Java parses
command,
which must be a string, to determine the executable and arguments.
| | envp |
An
Array
of strings of the form
name=value
that provide environmental variables to the executable.
| | error |
A
Stream
with
File
characteristics for reading error messages from the process.
| | exitvalue |
An
int
that provides the exit value of the process once
alive
is set back to zero.
| | input |
A
Stream
with
File
characteristics for writing input to the process.
| | output |
A
Stream
with
File
characteristics for reading output messages from the process.
| | parent |
A
Window
which is associated with the process so that if this window is disposed,
the process will be destroyed, the streams closed and the object reset.
| | persistent |
An
int
that is
0
(the default) if the process should be explictly stopped when the
Yoix interpreter exits.
Any other value means the process will be allowed to continue running
after the interpreter exits.
|
Several permanent fields have not been documented and should not be
used in Yoix applications.
| |
| Example: |
The following example is intended to be run on a UNIX-like OS that has the
X Windows system present and the xclock program available and accessible
via the
PATH
environmental variable.
The script specifies a
Process
object to run xclock with arguments to update itself every second.
The environment is set to display the clock in the local display, with
a size that is 82 pixels square and to
use the GMT timezone for the clock time.
A frame is then created with a check box to start and stop the process and
a button to exit the script.
import yoix.*.*;
Process clock = {
Array command = {"xclock", "-update", "1", "-geom", "82x82"};
Array envp = {"DISPLAY=:0.0", "TZ=GMT"};
};
Frame frame = {
String title = "Test";
Dimension size = NULL;
Point location = {
int x = 100;
int y = VM.screen.height - 200;
};
FlowLayout layoutmanager;
Array layout = {
new Checkbox {
String text = "Run";
int state = FALSE;
itemStateChanged(e) {
if (clock.alive = state) {
yoix.thread.sleep(0.1);
if (clock.error.ready)
stderr.nextbuf = clock.error.nextbuf;
}
};
},
new Button {
String text = "Quit";
actionPerformed(e) {
exit(0);
};
}
};
};
frame.visible = TRUE;
Incidentally, notice that
clock.error
is checked
for error messages right after starting the process.
If there are any messages, they will be written to
the standard error stream.
| | |
| See Also: |
exec
|
|
Yoix is a registered trademark of AT&T Inc.
|