* USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $Log: wirtcl.c,v $
- * Revision 1.8 1995/11/06 17:44:22 adam
+ * Revision 1.9 1995/11/07 14:56:59 adam
+ * Work on search in multiple targets.
+ * New wtcl command: wlog.
+ * Optional timeout parameter to zwait.
+ *
+ * Revision 1.8 1995/11/06 17:44:22 adam
* State reestablised when shell restarts. History of previous
* result sets.
*
};
-static int events (struct tcl_info *p, char *waitVar);
+static int events (struct tcl_info *p, char *waitVar, int tout);
static int proc_zwait_invoke (ClientData clientData, Tcl_Interp *interp,
int argc, char **argv)
if (argc < 2)
return TCL_OK;
- events (p, argv[1]);
- return TCL_OK;
+ return events (p, argv[1], (argc == 3) ? atoi(argv[2]) : 0);
}
}
-static int events (struct tcl_info *p, char *waitVar)
+static int events (struct tcl_info *p, char *waitVar, int tout)
{
int r, i;
char *cp;
gw_log (GW_LOG_DEBUG, mod, "Waiting %s=%s", waitVar, waitVarVal);
while (1)
{
+ struct timeval to, *top;
+ if (tout > 0)
+ {
+ to.tv_usec = 0;
+ to.tv_sec = tout;
+ top = &to;
+ }
+ else
+ top = 0;
+
if (!(cp = Tcl_GetVar (p->interp, waitVar, 0)) ||
strcmp (cp, waitVarVal))
{
FD_SET (fifo_in, &fdset_tcl_r);
#endif
if ((r = select(max_fd+1, &fdset_tcl_r, &fdset_tcl_w,
- &fdset_tcl_x, NULL)) < 0)
+ &fdset_tcl_x, top)) < 0)
{
gw_log (GW_LOG_ERRNO|GW_LOG_FATAL, mod, "select");
exit(1);
if (!r)
{
gw_log (GW_LOG_DEBUG, mod, "timeout");
- break;
+ free (waitVarVal);
+ return TCL_ERROR;
}
if (FD_ISSET (fifo_in, &fdset_tcl_r))
{
gw_log (GW_LOG_DEBUG, mod, "FIFO closed");
- break;
+ free (waitVarVal);
+ return TCL_ERROR;
}
for (i=0; i<=max_fd; i++)
{