Sublime Forum

How to detect sublime text exit

#1

What’s the right way to detect when Sublime Text exits?

I need it to kill a process when ST exits.

I assume plugin_unloaded would be called, but it isn’t (ubuntu, build 3211). It’s only called when I reload the python module (like save the python file).

I also thought that, regardless, the subprocess would be killed when the parent exited. After messing around, I think the problems comes from the fact that the program I start with subprocess creates a listening socket, and for some reason linux doesn’t kill it off.

One possible option is to kill the process as soon as there are no windows left (with an on_close event). The thing is that it doesn’t “semantically” make sense (the number of windows visible doesn’t imply anything about the state of the sublime text process), and that could result in a bug on mac os. I think that it’s common practice on their to have the process still running even without having any windows shown. I might be wrong, I don’t have anything to test on…

I also looked at how LSP did it. The “problem” is that in their case, it makes sense to shutdown the server when there are no windows left, which is what they do I’m pretty sure. They also use plugin_unloaded, but I’ve manually disabled that and their servers are still killed.

Any thought? Could someone confirm that behavior on mac os?

0 Likes

#2
0 Likes