`<' input to pass to the command
`>' output expected from the command
`!' metacommand, which can be one of:
- `set timeout' <integer>
+ `timeout' <integer>|no
`expect signal' <signal name>
`expect return' <integer>
`output' <ignore|display>
--------
By default, all commands are given 5 seconds to execute
-(cf. catch-timeout.tesh). You can change this with the "set timeout", which
+(cf. catch-timeout.tesh). You can change this with the "timeout", which
takes an integer as argument. The change only apply to the next command
-(cf. set-timeout.tesh).
+(cf. set-timeout.tesh). If you pass "no" as argument, the command
+cannot timeout.
OUTPUT
------
if (rctx->cmd)
rctx_start();
- if (!strncmp(line,"set timeout ",strlen("set timeout "))) {
- timeout_value=atoi(line+strlen("set timeout"));
+ if (!strncmp(line,"timeout no",strlen("timeout no"))) {
+ VERB1("[%s] (disable timeout)", filepos);
+ timeout_value = -1;
+ } else if (!strncmp(line,"timeout ",strlen("timeout "))) {
+ timeout_value=atoi(line+strlen("timeout"));
VERB2("[%s] (new timeout value: %d)",
filepos,timeout_value);
close(child_out[1]);
rctx->child_from = child_out[0];
- rctx->end_time = time(NULL) + timeout_value;
+ if (timeout_value > 0)
+ rctx->end_time = time(NULL) + timeout_value;
+ else
+ rctx->end_time = -1;
rctx->reader_done = 0;
rctx->reader = xbt_thread_create(thread_reader,(void*)rctx);
rctx->cmd);
/* Wait for the child to die or the timeout to happen (or an armageddon to happen) */
- while (!rctx->interrupted && !rctx->reader_done && rctx->end_time >= now) {
+ while (!rctx->interrupted && !rctx->reader_done && (rctx->end_time <0 ||rctx->end_time >= now)) {
usleep(100);
now = time(NULL);
}
xbt_mutex_lock(rctx->interruption);
- if (!rctx->interrupted && rctx->end_time < now) {
+ if (!rctx->interrupted && rctx->end_time > 0 && rctx->end_time < now) {
INFO1("<%s> timeouted. Kill the process.",rctx->filepos);
rctx->timeout = 1;
kill(rctx->pid,SIGTERM);