I'm modifying some code so that there is a timer on in. When the system has select(), I can just place a timer on select. However, what are some alternatives in the noselect case? Here is a code snippet to give you some idea,
Code:/*Here is the section that has a timer*/ #ifndef NOSELECT /* Set up the input file set for the select call */ FD_ZERO(&input_set); FD_SET(0,&input_set); FD_SET(rst,&input_set); struct timeval tv; tv.tv_sec = atoi(opt[OPT_IDLEOUT].str)*60; tv.tv_usec = 0; #endif /*What are some ideas that I could do this case?*/ #ifdef NOSELECT /* Copy text while I can -- otherwise go to input mode */ if (output()) { /*}*/ /* Wait four seconds for a command */ alarm(4); if (!setjump(jenv,1)) { read(0,&ch,1); /* Alarm busts us out of here */ alarm(0); docmd(ch); lastaction= time((time_t *)0); } #else /* Wait for input in file or from user */ iset= input_set; select(rst+1, &iset, NULL, NULL, &tv);/* process typed command from user */ if (FD_ISSET(0,&iset)) { read(0,&ch,1); docmd(ch); lastaction= time((time_t *)0); } /* process new text in file */ if (FD_ISSET(rst,&iset)) { while (!output()) ; #endif /*NOSELECT*/



LinkBack URL
About LinkBacks



CornedBee