Kbase P18242: Batch program containing the INPUT THROUGH statement fails sporadically
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  1/25/2010 |
|
Status: Verified
SYMPTOM(s):
Batch program containing the INPUT THROUGH statement fails sporadically
INPUT THROUGH ("move <file>").
INPUT THROUGH ("echo ?").
Process remains in memory and has to be killed
Following code became defunct after between 200 and 120,000 moves but remained functional after 1,000,000 moves on the single processor box.
def var i as int no-undo.
def var j as int no-undo.
def var c as char no-undo.
define stream st_in .
unix silent echo "Test" > /tmp/tdefunct1.
repeat:
i = i + 1.
pause 0.
if i mod 100 = 0 then disp i with frame a .
c = "mv /tmp/tdefunct" + string(i) +
" /tmp/tdefunct" + string(i + 1).
run exec-unix (c).
end.
procedure exec-unix:
define input parameter unix-line as char no-undo.
define var reterr as char no-undo.
define variable x as char no-undo.
define variable last-mess as char no-undo.
do :
input stream st_in through
value(unix-line + "; echo $?") no-echo.
repeat:
import stream st_in delimiter "\n" x.
last-mess = reterr.
reterr = x.
end.
input stream st_in close.
if reterr <> "0" then return error "UNIX ERROR:" + last-mess.
end.
end.
FACT(s) (Environment):
Progress 8.3E
HP-UX 11i 64-bit
CAUSE:
Migration to new machine, worked fine on HP-UX 10.20
FIX:
Read the result of the cmd in 2 steps: first execute the unix cmd and redirect the result to a file. and then read the file with an "input from" instead of an "input through"
procedure exec-unix:
define input parameter unix-line as char no-undo.
define var reterr as char no-undo.
define variable x as char no-undo.
def var idx as int no-undo.
define variable last-mess as char no-undo.
idx = random(1,100000000).
do on error undo, return error:
input stream st_in through
value( unix-line + "; echo $? > /tmp/dfct" + string(idx) )
no-echo.
repeat:
import stream st_in delimiter "\n" x.
last-mess = x.
end.
input stream st_in close.
input stream st_in from value ("/tmp/dfct" + string(idx)).
import stream st_in reterr.
input stream st_in close.
unix silent value ("rm /tmp/dfct" + string(idx) + " 2>
/dev
ull").
if reterr <> "0" then return error "UNIX ERROR:" + last-mess.
end.
end.