1

After starting some elf file that is on ext4 filesystem it is locked for writing but can be removed and rewritten. On some other filesystem this behaiveour can be different - i have tested virtualboxfs and there also I can not remove running executable file.

I am truing to implmenent some continuous integration scenario with self restarting and self compiling module. Thats why I need a possibility to unlock and overwrite somehow my running binary. For ext4 I can remove and then recompile file to the old place but I don't like this scenario, because inode with old file will be still blocked. Is there exists some other possibility to implement "transparent" recompilation and restart ?

1 Answer 1

3

What happens is that you acquire a file handler to that inode. You may remove the file ... but the file handler is still active. (therefore, even if the file is removed, the locked storage will not be freed)

If you want to replace the file, you need to reload the filehandler. The usual way to do it is by sending SIGHUP (kill -HUP)

If you need it to happen automatically when a file changes, you need a watchdog to do it on your behalf. Otherwise your script (or whatever) can send this signal to the process

3
  • Thanks for your answer can You abit explain details ? I have a running process - simply executable elf . In this process there is one thread that trackes changes of source files. and after changes it starts recompilation. if recompilation is successfull the old process starts a new copy ; does not accept new tasks and after all tasks are done it dies. Who on this scenario should send SIGHUP and what happens after that ? I have thought that SIGHUP - is signal to inform the process that terminal is off.
    – Oleg
    May 19, 2016 at 9:03
  • I have tried the following scenario but it does not work. gist.github.com/martende/3ccca3a97cb650808d2b83c4630ed258 I have used GO language but it can be replaced to some other
    – Oleg
    May 19, 2016 at 9:34
  • Have a look at this article. It gives a good insight of how it can be implemented. specs.openstack.org/openstack/glance-specs/specs/kilo/… May 19, 2016 at 10:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .