+ // see if we have any input that needs to go to the
+ // master pty
+ if(input_len > 0)
+ write(master, input_buf, 1);
+
+ // see if we have any output that needs to be echoed
+ // and written to the log
+ if(term_len > 0)
+ {
+ do
+ {
+ fwrite(term_buf, 1, 1, term_out);
+ write(1, term_buf, 1);
+ } while(read(master, term_buf, 1) > 0);
+ term_buf[0] = 0;
+ }
+
+ // nothing to read from dpkg , wait a bit for more