Win32\'s CreateFile has FILE_FLAG_DELETE_ON_CLOSE
, but I\'m on Linux.
I want to open a temporary file which will always be deleted upon program terminat
I just joined stackoverflow and found you here :)
If you're problem is to manage mq files and keep them from piling up, you don't really need to guarantee file deletion upon termination. If you just wanted to useless files from piling up, than keeping a journal may be all you need. Add an entry to the journal file after a mq is opened, another entry when it is closed, and when your library is initialized, check for inconsistency in the journal and take whatever action needed to correct the inconsistency. If you worry about crashing when mq_open/mq_close
is being called, you can also add an journal entry just before those functions are called.