Mail Archives: djgpp/1996/08/13/01:35:32
On 12 Aug 1996, Jens Jedamzik wrote:
> jacobsen AT kjemi DOT unit DOT no (Elling Jacobsen) wrote:
> > I have a program in which I write data records to a
> > number of files. My problem is that when I interrupt
> > the program using ctrl-C, the files are left empty. I guess
> > the reason is that the data are kept in memory and are
> > not dumped to file at interrupt? Is there any way to
> > ensure that all data records are written to file at
> > interrupt?
You should set up a signal handler for a signal named SIGINT. Whenever
Ctrl-C is pressed, that function will be called. In that function, just
call `exit'.
For more details about the `signal' function, look up its docs in the
on-line library reference (libc.inf).
- Raw text -