Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to inform other processes that a file has marked for deletion?

Tags:

c++

c

linux

I am currently writing a C application for an embedded system (limited disc space) On this system, several processes access files which I have to delete with my application on certain events (e.g. running out of disc space). But since the other processes still can write to these files, the disc space situation doesn't improve.

Is there any possibility to actually delete the file and let the write access of the other processes fail?

I have only limited access to the behavior of the other processes so it would be nice if no cooperation of these processes is needed.

like image 644
Andreas Wilkes Avatar asked Oct 22 '22 18:10

Andreas Wilkes


1 Answers

Two ideas come to mind to go around the fact that the file doesn't actually get deleted until all references to it are closed:

  1. if possible or permitted in your situation, unlink those files and then restart the other processes.
  2. truncate/empty those files without deleting them.
like image 193
Ionut Avatar answered Oct 26 '22 22:10

Ionut