launch_tor should kill process on exception while bootstrapping (for example, on KeyboardInterrupt)
What will happen if we will call
and CTRL+C some time after?
KeyboardInterrupt exception would be raised somewhere inside launch_tor, and we will have one of following situations:
- KeyboardInterrupt raised before or while subprocess.Popen - everything is ok
- KeyboardInterrupt raised after subprocess.Popen, inside bootstrapping, but before launch_tor finished - we will have hanging tor process with no ability to terminate it manually.
This issue is about to fix second case. All we need is to add handling of second situation inside launch_tor function. Here's example of code that should be added before line 165 inside stem.process:
except: # on any exception while bootstrapping tor_process.kill() # kill existing process raise # reraise exception
But note, you should also fix "finally" block to prevent closing stdout, stderr of terminated process.
Note, this issue is not only about KeyboardInterrupt, but also for any other exception that can be raised suddenly everyehere, like asyncio.CancelledError
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information