delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/07/12/06:00:27

From: "Edmund Horner" <edmund1 AT geocities DOT com>
Newsgroups: comp.os.msdos.djgpp
References: <963379268 DOT 280263 AT shelley DOT paradise DOT net DOT nz> <83aefniyuv DOT fsf AT mercury DOT bitbucket>
Subject: Re: Timers
Lines: 39
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2919.6600
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600
Organization: Paradise Net Ltd. Customer
Message-ID: <963395605.641606@shelley.paradise.net.nz>
Cache-Post-Path: shelley.paradise.net.nz!unknown AT 203-79-93-106 DOT tnt11 DOT paradise DOT net DOT nz
X-Cache: nntpcache 2.4.0b2 (see http://www.nntpcache.org/)
Date: Wed, 12 Jul 2000 21:54:45 +1200
NNTP-Posting-Host: 203.96.152.26
X-Complaints-To: newsadmin AT xtra DOT co DOT nz
X-Trace: news.xtra.co.nz 963395624 203.96.152.26 (Wed, 12 Jul 2000 21:53:44 NZST)
NNTP-Posting-Date: Wed, 12 Jul 2000 21:53:44 NZST
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Thank you so much, that was an excellent example.

Unfortunately it seems that this alarm will only be checked if DOS calls
(such as IO) are made.  Do you have any suggestions for getting around this?

"Nate Eldredge" <neldredge AT hmc DOT edu> wrote in message
news:83aefniyuv DOT fsf AT mercury DOT bitbucket...
> "Edmund Horner" <edmund1 AT geocities DOT com> 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


- Raw text -


  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019