[tor-bugs] #17946 [Stem]: launch_tor should kill process on exception while bootstrapping (for example, on KeyboardInterrupt)
Tor Bug Tracker & Wiki
blackhole at torproject.org
Tue Dec 29 03:05:25 UTC 2015
#17946: launch_tor should kill process on exception while bootstrapping (for
example, on KeyboardInterrupt)
------------------------+-----------------------------------
Reporter: germn | Owner: atagar
Type: defect | Status: new
Priority: Medium | Milestone:
Component: Stem | Version:
Severity: Normal | Keywords: launch_tor, bootstrap
Actual Points: | Parent ID:
Points: | Sponsor:
------------------------+-----------------------------------
What will happen if we will call
{{{
stem.process.launch_tor_with_config(config, timeout=None)
}}}
and CTRL+C some time after?
KeyboardInterrupt exception would be raised somewhere inside launch_tor,
and we will have one of following situations:
1) KeyboardInterrupt raised before or while subprocess.Popen - everything
is ok
2) 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
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/17946>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
More information about the tor-bugs
mailing list