COPROC(1F)(Form and Menu Language Interpreter Utilities)
COPROC(1F)
NAME
cocreate, cosend, cocheck, coreceive, codestroy -
communicate to a process
SYNOPSIS
cocreate [-r rpath] [-w wpath] [-i id] [-R refname] [-s
send_string]
[-e expect_string] command
cosend [-n] id string
cocheck id
coreceive id
codestroy [-R refname] id
DESCRIPTION
The cocreate built-in initializes communication to a process
using named-pipes. This means that the process will expect
strings on its input and send information on its output.
The cosend built-in works two ways. With the -n option,
cosend does not wait for a response. The process should use
vsig to force the strings into the pipe and then signal that
it wishes to send. This causes a reread to occur in the
current frame. The vsig executable is supplied on the FMLI
disk, and is described in detail on the vsig(1F) manual page
in chapter 4 of the FMLI Programmer's Guide.
The cocheck built-in should be called from a reread
descriptor. The default value of one of the fields in the
form should include the coreceive.
Without the -n option, send_string and expect_string are
used to tell when input and output are completed on the
pipe. In other words, the Interpreter during a cosend will
put out all the strings given as arguments followed by
send_string, to say that it is done giving information.
Then it will read all the output from the process until it
sees expect_string. By default, the Interpreter will send
no send_string and expect no expect_string (it will expect
only one line of output from the process). Read the warning
below if you use cosend without the -n option.
Page 1 May 1989
COPROC(1F)(Form and Menu Language Interpreter Utilities)
COPROC(1F)
The codestroy built-in should usually be given the -R
option, as you may have more than one process with the same
name, and you don't want to kill the wrong one. It keeps
track of the number of refnames you have assigned, and when
the last one is killed, kills the process (id) for you.
The id is used to refer to the process. If none is
specified, the name of the process is used.
The refname is a "local" name for a process. This is useful
when multiple objects reference the same process (i.e., when
multiple objects perform a cocreate on the same process).
Thus, when a codestroy operation is performed you will
usually want to destroy only the local reference to the
process rather than the entire pipe.
The rpath tells cocreate what file to use to read
information from. The wpath tells cocreate what file to use
to write information to. These files are usually used for
processes that naturally write to a certain pipe or for
having one process talk to many different Interpreters. If
rpath and wpath are not specified, paths will be picked in
$HOME/tmp.
The command argument should be a program followed by its
arguments.
Here is some advice for writing these programs. If this
program is to be written in "C", make sure to flush output
after writing to the pipe (a good way to check this is to
run cat | prog | cat from shell). As of this writing,
awk(1) and sed(1) can not be used because they do not flush
after lines of output. Shell scripts are well-mannered, but
slow. "C" is recommended. If possible, use the default
send_string, rpath and wpath. In most cases, the
expect_string will have to be specified. (Note: the
expect_string need only be the initial part of the line, and
there must be a new-line at the end of the output). The id
is usually used when the same process is used with different
options and different meanings.
Page 2 May 1989
COPROC(1F)(Form and Menu Language Interpreter Utilities)
COPROC(1F)
The codestroy built-in will usually work best in "close="
lines in menus and forms. The "close=" is guaranteed to be
evaluated when a window is closed.
EXAMPLE
.
.
.
init=`cocreate -i BIGPROCESS initialize`
close=`codestroy BIGPROCESS`
.
.
.
reread=`cocheck BIGPROCESS`
name=`cosend -n BIGPROCESS field1`
.
.
.
name="Receive field"
inactive=TRUE
value=`coreceive BIGPROCESS`
WARNING
If cosend is used without the -n option, a coprocess that
does not answer will cause the Interpreter to permanently
hang.
SEE ALSO
awk(1), sed(1), cat(1)
Page 3 May 1989