SUMMARY Every week I must manually clean out thousands of konsole-*.history temporary files from /tmp totaling hundreds of megabytes. STEPS TO REPRODUCE 1. Use konsole for some days or weeks. OBSERVED RESULT Low disk space on drive, sometimes causing complete failure to boot system. Must manually clean them out from /tmp, sometimes from another distro before even being able to boot. Average user has no clue what is going on behind their back, and why the system won't boot. EXPECTED RESULT There should be no history files hanging around when konsole is not running. SOFTWARE/OS VERSIONS OpenSUSE Tumbleweed. ADDITIONAL INFORMATION Please make konsole clean up after itself when it closes. Even better: When konsole starts, please check if stale history file are hanging around and delete them before continuing. (Can you see the bizarre irony that these are supposed to be 'temporary' files but they hang around forever?) Thank you.
By any chance is Konsole crashing at some point? Or is your system crashes or quitting the desktop? Otherwise, Konsole should remove those upon a clean quit. I don't think Konsole can clean out those files upon startup since another Konsole could be running. Also what version are you running?
Create + open + unlink should fix any possible problem with leftover files. From man 2 unlink: unlink() deletes a name from the filesystem. If that name was the last link to a file and no processes have the file open, the file is deleted and the space it was using is made available for reuse. If the name was the last link to a file but any processes still have the file open, the file will remain in existence until the last file descriptor referring to it is closed.
Thank you for the response. Konsole (ver 19.08.1) does not crash, nor the system. The only thing I can think of that might be unusual is that I leave Konsole open when I shut down, ie. I leave Konsole open all the time so that it is opened upon reboot. I will try some experiments to see if that might be the problem, maybe Konsole is not being given enough time to clean up as the system shuts down. Until recently Konsole was indeed frequently crashing upon shutdown. That appears to have been fixed here in openSuse Tumbleweed. But the temp files still seem to be appearing and left around despite cleaning.
Verified: Konsole cleans up after itself if I manually close it. But Konsole does not clean up if left open and reboot. I began with a clean plate and started Konsole and verified it cleans up if I close it. But if I leave Konsole open and reboot, the temp files are still there. Each time I reboot, a whole new set of Konsole temp files appears. After several reboots, I now have dozens of files. Hope I'm not 'barking up the wrong tree'. Maybe a system problem? (Seems that's taking reboot 'restoration' to an extreme. Is normal?) I have several apps open but none seem to use temp files. I will try to find another app which uses temp files and verify. Any suggestions or ideas of cause? Thanks.
I almost forgot, KDevelop is another app that populates the /tmp folder. KDevelop does not leave anything there upon reboot, and cleans up despite being a 600lb gorilla having a big project open and many huge temp files. Something wrong in Konsole? Konsole was for a long time crashing upon reboot until recently. Maybe some bugs still being worked out. This is openSuse Tumbleweed after all, where things update daily... I'm ready to quickly test anything you might want to try, as soon as it comes down the pipeline. Thanks.
Reverting this should help: https://invent.kde.org/kde/konsole/commit/660559600f1663e4538611870d1fcde418e55704 This code creates named file, which must be removed by working program. Unnamed files are removed by kernel automatically. Access to unnamed files (under linux) is provided through /proc/XXX/fd/: lrwx------ 1 mglb mglb 64 Oct 9 00:58 17 -> '/tmp/#6060213 (deleted)' lrwx------ 1 mglb mglb 64 Oct 9 00:58 18 -> '/tmp/#6060214 (deleted)' lrwx------ 1 mglb mglb 64 Oct 9 00:58 19 -> '/tmp/#6060215 (deleted)' I'll test it tomorrow.
Thanks for the tip. I did not know that about QTemporayFile. It does not appear to specifically mention that in the docs. I began using that class in our app recently. I read a topic somewhere "How long do temporary files made with mktemp last?" with posts explaining in detail and mentioned checking 'TMPTIME', or /etc/cron.daily/tmpwatch. Both don't seem to exist here.
Fix: https://invent.kde.org/kde/konsole/merge_requests/39 Should also work on systems where QTemporaryFile does not create unnamed files.
We could revert https://invent.kde.org/kde/konsole/commit/660559600f1663e4538611870d1fcde418e55704 - and perhaps just leave a note when debugging history files to re-add it.
committed in 0f19efa5b27c4f90a6195265533df1ddc214d936