Date: Tue, 13 Aug 1996 08:30:08 +0200 (IST) From: Eli Zaretskii To: Jens Jedamzik , Elling Jacobsen Cc: djgpp AT delorie DOT com Subject: Re: interrupting with ctrl-C In-Reply-To: <4ungbb$bqa@news.uni-paderborn.de> Message-Id: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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).