www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/01/16/06:32:44

Date: Thu, 16 Jan 1997 13:11:28 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: "x DOT pons AT cc DOT uab DOT es" <ILGES AT cc DOT uab DOT es>
cc: djgpp AT delorie DOT com
Subject: Re: How to receive a time message.
In-Reply-To: <01IE9WPF9MR6003WGX@cc.uab.es>
Message-ID: <Pine.SUN.3.91.970116130109.17153A-100000@is>
MIME-Version: 1.0

On Thu, 16 Jan 1997, x DOT pons AT cc DOT uab DOT es wrote:

> I am writting a program that should be interrupted after 't' seconds of
> execution. During this time, the user should be able to interact with
> my program (entering keyboard data).

Define a handler for the signal SIGALRM and call library function `alarm'. 
A call like "alarm (10);" will cause SIGALRM to be generated 10 seconds
from now.  When that happens, your handler is called, and you may do
whatever pleases you there, including keyboard input.  When your handler
returns, the program will resume at the point it was interrupted.  The
library reference for `alarm' has the rest of details.  If you never
before wrote a signal handler, please also read the docs of library
function `signal'. 

Note that due to specifics of signal support in DJGPP, your handler is 
only called when the program is in protected mode and touches some of its 
data, so in reality the program might be interrupted not exactly at the 
moment you want but somewhat later.  The latency depends on the amount of 
time your program spends doing DOS I/O or real-mode BIOS calls.  The 
above approach is a good technique if you don't care much about the 
accuracy of the moment when the program is interrupted.

- Raw text -


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