- child_stdin = fdopen(stdin_pair[1], "w");
- close(stdin_pair[0]); // child stdin read
- close(stdout_pair[1]); // child stdout write
-
- #else
- // llogin or other
- child_stdin = popen("llogin door -w -", "w");
- if( !child_stdin || child_stdin == (void*)-1 ) {
- #if DEBUG
- printf("Door_DoDispense: llogin failure\n");
- #endif
- return -1;
- }
- #endif
-
- if(fread(buf, 1, 512, child_stdin) == 0) {
- #if DEBUG
- printf("Door_DoDispense: fread fail\n");
+ child_stdin = fdopen(child_stdin_fd, "w");
+
+ int read_child_output()
+ {
+ char buf[1024];
+ int len;
+ if( giDoor_ChildStatus || (len = read(child_stdin_fd, buf, sizeof buf)) < 0)
+ {
+ #if DEBUG
+ printf("Door_DoDispense: fread fail\n");
+ #endif
+ return -1;
+ }
+ buf[len] = '\0';
+
+ #if DEBUG > 1
+ printf("Door_DoDispense: buf = %i '%s'\n", len, buf);