irony-mode
irony-mode copied to clipboard
Removal of temporary files
Hello. When using irony-server some temporary files are created whose name is in the form "preable-*.pch". These files remain after I close Emacs and they accumulate. When /tmp is mounted as a RAM space on Linux, the memory usage goes up steadily with multiple projects/instances, with a multitude of preamble files in the order of a few MB each. Is it possible to dispose of the temporary files when irony exits?
The issue comes from shutdown down the process too harshly. If I close libclang normally, the preamble is deleted automatically. I need to install a signal handler I guess, but not sure how portable it is as there is a few Windows user around here.
Good remark. From what I have discovered from Emacs source code and MSDN, here's a few relevant points.
First, neither Emacs function delete-process or kill-process can allow the process to clean up, because both of these generate SIGKILL. On the other other hand interrupt-process produces the catchable SIGINT or the equivalent console-break on Windows.
According MS Windows's limited implementation of signals, installing a handler on SIGINT allows to catch the said console break, so we could have a portable cleanup code. (for reference you can see how Emacs does kill on Win32 in src/w32proc.c)
Thanks, for the record, yesterday I started working on this and I replaced kill-process by interrupt-process indeed. But I stopped at std::getline()
not quiting on SIGINT...
Yes I can see what the problem is... I don't know how to simply fix this. I can think of a solution which would work but complicates architecture and it's kind of crap. That would be to go lower level and involve sockets. It's what I do usually, on win32 the socket is the only kind of descriptor which you can select() on. From the signal handler one could wake up the main thread by writing into the socket.. Winsock does not have the socketpair() function but there are some implementations around in the public domain license.
How about defining a quit command in the communication protocol with the libclang process?
There is one indeed, and that should work. I still think SIGINT should be handled but the exit
command could do the trick alone.