--- libaitio/example/test_exec.c 2013/12/05 16:02:02 1.1.2.4 +++ libaitio/example/test_exec.c 2013/12/06 01:03:02 1.1.2.7 @@ -1,4 +1,7 @@ #include +#include +#include +#include #include #include @@ -7,7 +10,9 @@ int main(int argc, char **argv) { prog_t *p; + FILE *f; int ret = 0; + char str[BUFSIZ]; if (argc < 2) return 1; @@ -30,6 +35,35 @@ main(int argc, char **argv) goto end; } + printf("last=%d\n", array_Last(p->prog_fds)); + + ret = io_progGrow(p, 8); + printf("+grow_progs=%d\n", ret); + + printf("wait for keystroke %p ", p); + getchar(); + + ret = io_progVacuum(p, 5); + printf("+vacuum_progs=%d\n", ret); + + printf("wait for keystroke %p ", p); + getchar(); + +again: + f = io_progAttach(p); + printf("f=%p\n", f); + while (read(fileno(f), str, sizeof str) > 0) { + printf(">>> %s", str); + fgets(str, sizeof str, stdin); + if (*str == '.') + break; + write(fileno(f), str, strlen(str)); + } + io_progDetach(p, f); + + printf("wait for keystroke %p ", p); + if (getchar() == 'a') + goto again; end: io_progDestroy(&p); return ret;