Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dub run leaves behind temp files #536

Open
MartinNowak opened this issue Mar 29, 2015 · 4 comments
Open

dub run leaves behind temp files #536

MartinNowak opened this issue Mar 29, 2015 · 4 comments

Comments

@MartinNowak
Copy link
Member

Found a huge amount of dub temp files in my /tmp/ folder.
Seems like dub relies on static ~this() to cleanup temp files, but that is never called if you dub run a tool and exit it via CTRL+C.

@mihails-strasuns
Copy link

This must be a side effect of my attempt at tmp file randomization. I did put all removal in one place there because original way felt overly error prone - some bits of code did remove files but ones that were rarely called sometime forgot it.

I am surprised module destructors are not being run upon receiving SIGINT. It is not a critical signal like SIGABRT and resource cleanup should be done as normally. This sounds like druntime bug.

@MartinNowak
Copy link
Member Author

You can't do much in a signal handler (because you might easily dead-lock) and installing a signal handler to perform cleanup comes with a lot of other difficulties, e.g. inadvertently catching SIGINT from a child, overriding other handlers. It's not something you want to add to druntime (atexit doesn't seem to run either).
Seems like this mostly happens with dub run, so the SIGINT is actually meant to terminate the child process but kills dub as well.

@mihails-strasuns
Copy link

One option could be to simply set internal druntime flag in sigint handler and check it upon entering any druntime function (SIGINT does not specify how soon application must terminate, it is allowed to even ignore it). I understand that there is no easy & clean solution here but just accepting existing situation makes destructors even more useless than they normally are (I kind of accepted lack of class destructors but this also removes struct and module ones)

@MartinNowak
Copy link
Member Author

Related, sometimes dub leaves .lock files behind, apparently when getting killed (SIGABRT?) during fetching a package. Those block (timeout) later attempts to retrieve that package and need manual intervention.
We should use a better lockfile implementation that can deal with dead owners and/or cleanup stuff even on signals.

@MartinNowak MartinNowak changed the title dub run leaves behind temp files dub run leaves behind temp (and lock) files Feb 10, 2017
@MartinNowak MartinNowak changed the title dub run leaves behind temp (and lock) files dub run leaves behind temp files Sep 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants