OK, I think the following clearly indicates the sync problem we're running
into. This is a tiny example of a program that prompt for input and then
returns (fixed) output.
$cat hiho.c
#include<stdio.h>
#include<unistd.h>
int main(int argc, char** argv) {
char *line[1000];
size_t len = 0;
ssize_t readlen;
while (1) {
printf("prompt:");fflush(stdout);
readlen=read(0,line,1000);
printf("received 'hiho'\n",line);
};
}
$ gcc hiho.c -o hiho
$ sage
[...]
sage: %cpaste
Pasting code; enter '--' alone on the line to stop or use Ctrl-D.
:import pexpect
:child=pexpect.spawn("env ./hiho")
:i=0
:s='hiho'
:Atemplate = s+"\r\n"
:Btemplate = "received '%s'\r\n"%s
:while true:
: i+=1
: u=child.expect('prompt:')
: u=child.sendline(s)
: A=child.readline()
: B=child.readline()
: if A != Atemplate:
: print "ERROR! received %s"%repr(A)
: break
: if B != Btemplate:
: print "ERROR! received %s"%repr(B)
: break
: if (i%100) == 0:
: print "completed iteration %d"%i
:--
completed iteration 100
completed iteration 200
ERROR! received "hihoreceived 'hiho'\r\n"
This stuff is very sensitive! For instance, using "getline" rather than
"read did not allow me to trigger the error, and also with read it is very
hard to get it triggered. It's interesting that Singular seems so apt at
triggering the condition (how much tighter than the loop above can we get?)
--
You received this message because you are subscribed to the Google Groups
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/groups/opt_out.