- FD_ZERO (&fdset_tcl);
- FD_SET (0, &fdset_tcl);
- for (i=3; i<MAX_CALLBACK; i++)
- if (callback_table[i].handle)
- FD_SET (i, &fdset_tcl);
- if ((res = select(MAX_CALLBACK+1, &fdset_tcl, 0, 0, 0)) < 0)
+ FD_ZERO (&fdset_tcl_r);
+ FD_ZERO (&fdset_tcl_w);
+ FD_ZERO (&fdset_tcl_x);
+ if (interactive)
+ FD_SET (0, &fdset_tcl_r);
+ for (res=0, i=min_fd; i<=max_fd; i++)
+ {
+ if (callback_table[i].w_handle)
+ {
+ FD_SET (i, &fdset_tcl_w);
+ res++;
+ }
+ if (callback_table[i].r_handle)
+ {
+ FD_SET (i, &fdset_tcl_r);
+ res++;
+ }
+ if (callback_table[i].x_handle)
+ {
+ FD_SET (i, &fdset_tcl_x);
+ res++;
+ }
+ }
+ if (!interactive && !res)
+ return;
+ if ((res = select(max_fd+1, &fdset_tcl_r, &fdset_tcl_w,
+ &fdset_tcl_x, 0)) < 0)