Index: asterisk.c =================================================================== RCS file: /usr/cvsroot/asterisk/asterisk.c,v retrieving revision 1.81 diff -u -r1.81 asterisk.c --- asterisk.c 4 May 2004 14:54:42 -0000 1.81 +++ asterisk.c 9 May 2004 08:31:40 -0000 @@ -64,6 +64,7 @@ int option_highpriority=0; int option_remote=0; int option_exec=0; +int option_timeout=0; int option_initcrypto=0; int option_nocolor; int option_dumpcore = 0; @@ -841,6 +842,7 @@ max++; } res = poll(fds, max, -1); +moredata: if (res < 0) { if (errno == EINTR) continue; @@ -870,6 +872,10 @@ write(STDOUT_FILENO, buf, res); if ((buf[res-1] == '\n') || (buf[res-2] == '\n')) { *cp = CC_REFRESH; + if (option_exec && option_timeout) { + if ((res = poll(fds, max, option_timeout))) + goto moredata; + } return(1); } else { lastpos = 1; @@ -1379,6 +1385,7 @@ printf(" -q Quiet mode (supress output)\n"); printf(" -g Dump core in case of a crash\n"); printf(" -x Execute command (only valid with -r)\n"); + printf(" -t Wait timeout miliseconds to exit after executing cmd (only valid with -x)\n"); printf(" -i Initializie crypto keys at startup\n"); printf(" -c Provide console CLI\n"); printf(" -d Enable extra debugging\n"); @@ -1483,7 +1490,7 @@ } */ /* Check for options */ - while((c=getopt(argc, argv, "hfdvqprgcinx:C:")) != -1) { + while((c=getopt(argc, argv, "hfdvqprgcinx:t:C:")) != -1) { switch(c) { case 'd': option_debug++; @@ -1524,12 +1531,15 @@ case 'i': option_initcrypto++; break; - case'g': + case 'g': option_dumpcore++; break; case 'h': show_cli_help(); exit(0); + case 't': + option_timeout = atoi(optarg); + break; case '?': exit(1); }