jskinner / DefaultPackages

Old bug tracker for Sublime Text's "Default Packages", e.g. bad syntax highlighting
http://web.archive.org/web/20150524043750/https://www.sublimetext.com/forum/viewtopic.php?f=2&t=12095
26 stars 2 forks source link

Cancel Build should continue showing output until process is dead #107

Closed hamiltont closed 8 years ago

hamiltont commented 9 years ago

Using Cancel Build sends a SIGTERM on linux, which is a method of politely asking a process to stop. Many processes will clean up some resources before stopping, and will likely produce a bit more output while this happens. Currently ST stops sending any output once a process has been asked to terminate, due to concerns that starting a new build right after finishing a prior build would result in output from both builds becoming mixed. I'd advocate that ST continues showing output from the old process, but prefixes it with something like [Shutting Down] or [Dying]. The current user experience immediately shows [Cancelled] and no more output happens, which confuses users like myself because it seems exactly like a SIGKILL (where the program is immediately terminated and given no chance to clean up resources).

The critical file appears to be exec.py, where the append_* function checks if self.proc and decides to send no more output.

This python program shows the issue:

import atexit
import time

def cleanup_expensive_resource():
    print("Finished cleaning up expensive resource")

def do_something():
    print("Using expensive resource")
    atexit.register(cleanup_expensive_resource)
    time.sleep(20)

if __name__ == "__main__":
  do_something()
  print("Program done, exiting")

Sublime Output, using Cancel Build During the 20s wait

Using expensive resource
[Cancelled]

Traditional Python Output, using Ctrl-C During 20s wait

Hamiltons-MacBook-Pro:src hamiltont$ python test.py
Using expensive resource
^CTraceback (most recent call last):
  File "test.py", line 14, in <module>
    do_something()
  File "test.py", line 11, in do_something
    time.sleep(20)
KeyboardInterrupt
Finished cleaning up expensive resource
FichteFoll commented 8 years ago

This issue was moved to SublimeTextIssues/Core#1186