From: Nate Eldredge Newsgroups: comp.os.msdos.djgpp Subject: Re: Timers Date: 12 Jul 2000 00:36:40 -0700 Organization: Posted via Supernews, http://www.supernews.com Lines: 28 Sender: nate AT mercury DOT bitbucket Message-ID: <83aefniyuv.fsf@mercury.bitbucket> References: <963379268 DOT 280263 AT shelley DOT paradise DOT net DOT nz> X-Complaints-To: newsabuse AT supernews DOT com User-Agent: Gnus/5.0802 (Gnus v5.8.2) Emacs/20.5 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com "Edmund Horner" writes: > Requisite greetings to all, > > I'd like to be able to write a program that quits after a certain duration > (say 5 minutes), and I expect this means using interrupts. > > Can anyway here give me a couple of tiny snippets of code as to how this can > be achieved? Use the alarm function. void handler(int signum) { clean_up(); printf("Bye bye\n"); exit(0); } ... signal(SIGALRM, handler); alarm(5 * 60); ... -- Nate Eldredge neldredge AT hmc DOT edu