Clean exit after CTRL+C
Markku M{enp{{
jackin at vehka.uta.fi
Mon Jul 30 22:23:42 AEST 1990
My program uses temporary files all the time. To allow clean exit
after CTRL+C, I put all names of the opened temporary files in
a static table. When my signal handler detects a CTRL+C, it reads
the table and removes all the files from the table and deletes them
from the disk.
My problem occures when I call an another program from my program.
I first redirect the stdout to a file and then call the program,
whose output goes into the file. If CTRL+C is pressed during the
called program it exits cleanly (this leaves no files). Now the
parent programs' signal handler also receives CTRL+C and goes to
do what it was designed to do, but the redirection is still in
effect and the associated stream is still open. So it can not be
deleted. So there is one file I have to get rid of. How can this
be taken care of ?
Note that I can't pass any parameters to my signal handler, all
is done via static variables. I use fclosall() which doesn't close
stdout or stderr.
I thank you for your help,
Markku (jackin at vehka.uta.fi)
More information about the Comp.lang.c
mailing list