Yep - named pipes are what I've been experimenting with - but without success. (BTW - I've used named pipes in the past between scripts without a problem.)
Here is what I've been playing with:
ksh script:
# cat test.ksh
#!/usr/bin/ksh93
export ASK=/tmp/ask
export REPLY=/tmp/reply
function isalive {
kill -0 $BKPID >/dev/null 2>/dev/null
STAT=$?
if [[ "x$STAT" != x0 ]]
then
echo "4GL program is dead"
else
echo "4GL program is alive"
fi
}
umask 000
rm -f $ASK
rm -f $REPLY
mknod $ASK p
mknod $REPLY p
chmod 777 $ASK $REPLY
set -x
/u0/dlc/bin/_progres -b -p /u0/DL/bin/test.p > /tmp/othertmp &
BKPID=$!
sleep 3
isalive
echo "abc" >> $ASK
isalive
read ANSA < $REPLY
isalive
print $ANSA
isalive
echo "def" >> $ASK
isalive
read ANSA < $REPLY
isalive
print $ANSA
isalive
echo "ghi" >> $ASK
read ANSA < $REPLY
print $ANSA
read PORZ
And here is the 4GL program:
# cat test.p
DEF VAR w_innod AS CHAR NO-UNDO.
DEF VAR w_outnod AS CHAR NO-UNDO.
DEF VAR w_reply AS CHAR NO-UNDO.
DEF STREAM indata.
DEF STREAM outdata.
DEF STREAM logdata.
ASSIGN w_innod = OS-GETENV("ASK")
w_outnod = OS-GETENV("REPLY").
OUTPUT STREAM logdata TO /tmp/tmplog.
PUT STREAM logdata "Started" SKIP.
INPUT STREAM indata FROM VALUE(w_innod) UNBUFFERED.
OUTPUT STREAM outdata TO VALUE(w_outnod).
PUT STREAM logdata "Streams opened" SKIP.
IMPORT STREAM indata UNFORMATTED w_reply.
EXPORT STREAM outdata "#1: " w_reply.
PUT STREAM logdata "First set done. w_reply:" w_reply FORMAT "x(60)" SKIP.
IMPORT STREAM indata UNFORMATTED w_reply.
EXPORT STREAM outdata "#2: " w_reply.
PUT STREAM logdata "Second set done. w_reply:" w_reply FORMAT "x(60)" SKIP.
IMPORT STREAM indata UNFORMATTED w_reply.
EXPORT STREAM outdata "#3: " w_reply.
INPUT STREAM indata CLOSE.
OUTPUT STREAM outdata CLOSE.
PUT STREAM logdata "Program done" SKIP.
When I execute the script, this is what is displayed:
# ./test.ksh
+ BKPID=6789
+ /u0/dlc/bin/_progres -b -p /u0/DL/bin/test.p
+ sleep 3
+ 1> /tmp/othertmp
+ isalive
4GL program is
alive
+ echo abc
+ 1>> /tmp/ask
+ isalive
4GL program is
alive
+ read ANSA
+ 0< /tmp/reply
+ isalive
4GL program is
dead
+ print '"#1:' '"' '"abc"'
"#1: " "abc"
+ isalive
4GL program is
dead
+ echo def
And at that point the script hangs.
The log from the 4GL code is:
# cat tmplog
Started
Streams opened
First set done. w_reply:abc
As you can see - the first send/receive has worked - but then the 4GL program dies - and I don't know why.
Any suggestions very welcome!
Ron. 