|
|
| version 1.1.2.1, 2013/12/05 12:45:53 | version 1.1.2.7, 2013/12/06 01:03:02 |
|---|---|
| Line 1 | Line 1 |
| #include <stdio.h> | #include <stdio.h> |
| #include <unistd.h> | |
| #include <string.h> | |
| #include <errno.h> | |
| #include <aitio.h> | #include <aitio.h> |
| #include <sys/wait.h> | |
| int | int |
| main(int argc, char **argv) | main(int argc, char **argv) |
| { | { |
| prog_t *p; | |
| FILE *f; | |
| int ret = 0; | |
| char str[BUFSIZ]; | |
| if (argc < 2) | if (argc < 2) |
| return 1; | return 1; |
| return 0; | p = io_progInit(argv[1], 3, 10); |
| if (!p) { | |
| ELIBERR(io); | |
| return 2; | |
| } else if ((ret = io_progCheck(p))) { | |
| printf("0.exited procs=%d\n", ret); | |
| goto end; | |
| } else { | |
| printf("wait for keystroke %p ", p); | |
| getchar(); | |
| } | |
| ret = io_progCheck(p); | |
| if (ret) { | |
| printf("1.exited procs=%d\n", ret); | |
| 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; | |
| } | } |