Opened 5 years ago

Closed 5 years ago

#14419 closed defect (user disappeared)

Suggestion to Kill Tor Process before Starting

Reported by: icodemachine Owned by: atagar
Priority: Low Milestone:
Component: Core Tor/Stem Version:
Severity: Keywords: controller, easy
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

When I started out using Stem, I tried launching Tor, but failed because of a few errors. Currently, there isn't a kill process method to kill the tor.exe process in the case of failed launch method. So, when we re-use the function again, a new error arises, 'Failed to Bind to one of the listener Ports'. So, it thought why not kill the process if it exists, in the case of failed launch.

Child Tickets

Change History (3)

comment:1 Changed 5 years ago by atagar

Keywords: controller easy added

Hi icodemachine, good point! It would definitely be good for the process module to ensure its daemon is gone if it raises an exception. I have quite a few other things on my plate but I'll get to this soonish.

Thanks for the suggestion!

comment:2 Changed 5 years ago by atagar

Status: newneeds_information

Hi icodemachine, I just tried to add an integ test for this but seems the tor process dies on its own...

    # Set the same SocksPort and ControlPort, this should fail with...
    #   
    #   [warn] Failed to parse/validate config: Failed to bind one of the listener ports.
    #   [err] Reading config failed--see warnings above.

    def init_line_handler(line):
      print line

    runner = test.runner.get_runner()
    tor_process = stem.process.launch_tor_with_config(
      tor_cmd = runner.get_tor_command(),
      config = { 
        'SocksPort': '2777',
        'ControlPort': '2777',
        'DataDirectory': self.data_directory,
      },  
      init_msg_handler = init_line_handler,
    )   

... causes the following tor output which seems to be what you're hitting...

Feb 01 13:15:52.723 [notice] Tor v0.2.6.2-alpha-dev (git-518b0b3c5fefba24) running on Linux with Libevent 2.0.16-stable, OpenSSL 1.0.1 and Zlib 1.2.3.4.
Feb 01 13:15:52.723 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning
Feb 01 13:15:52.724 [notice] This version is not a stable Tor release. Expect more bugs than usual.
Feb 01 13:15:52.724 [notice] Read configuration file "/tmp/torrc-lUvE6k".
Feb 01 13:15:52.745 [warn] ControlPort is open, but no authentication method has been configured.  This means that any program on your computer can reconfigure your Tor.  That's bad!  You should upgrade your Tor controller as soon as possible.
Feb 01 13:15:52.748 [notice] Opening Socks listener on 127.0.0.1:2777
Feb 01 13:15:52.748 [notice] Opening Control listener on 127.0.0.1:2777
Feb 01 13:15:52.748 [warn] Could not bind to 127.0.0.1:2777: Address already in use. Is Tor already running?
Feb 01 13:15:52.749 [notice] Closing partially-constructed Socks listener on 127.0.0.1:2777
Feb 01 13:15:52.749 [warn] Failed to parse/validate config: Failed to bind one of the listener ports.
Feb 01 13:15:52.749 [err] Reading config failed--see warnings above.

But after the tests finish there's no lingering tor processes...

% pidof tor | wc -l
0

Any thoughts on what's missing?

comment:3 Changed 5 years ago by atagar

Resolution: user disappeared
Status: needs_informationclosed

Hi icodemachine, cleaning up this ticket. Feel free to reopen if this is still an issue.

Note: See TracTickets for help on using tickets.