Open System Services Programmer's Guide

#unframe
== Display output from previously defined OSSTTY/OSS shell environment
?section print routine
#frame
#push pname out^line
#if [#argument /value pname/ processname]
#if [#argument end]
#chardel pname 1 for 1
[#if not [#variableinfo /existence/ [pname]^in^buf] |then|
#output Process not known.
#output
#unframe
#return
] == end if
[#loop |while| [[pname]^need^prompt] |do|
#delay 1 == Get out of the way of the shell
#set out^line [#extract [pname]^out^buf]
[#if not [#emptyv [pname]^status] |then|
#set [pname]^need^prompt 0
#output Process $[pname] died ([[pname]^status]). Cleaning up.
#output
#outputv [pname]^out^buf
unsh $[pname]
#unframe
#return
] == end if not emptyv pname^status then
[#if [#match [[pname]^prompt^buf] [out^line]] |then|
#set [pname]^need^prompt 0
|else|
#outputv out^line
] == end if
] == end loop
#unframe
== Enter interactive mode with previously defined OSSTTY/OSS
== shell environment
?section be routine
#frame
#push pname done in^line out^line
#if [#argument /value pname/ processname]
#chardel pname 1 for 1
[#if not [#variableinfo /existence/ [pname]^in^buf] |then|
#output Process not known.
#output
#unframe
#return
] == end if
#set done 0
[#loop |while| not [done] |do|
#inputv in^line [pname]^prompt^buf
[#if [#inputeof] |then|
#set done -1
|else|
#set [pname]^out^buf
#appendv [pname]^in^buf in^line
#set [pname]^need^prompt -1
sink [#wait [pname]^out^buf [pname]^status]
Using OSSTTY to Redirect Input and Output to Guardian Objects 225