[tor-bugs] #9376 [Pluggable transport]: subprocess management module for pyptlib

Tor Bug Tracker & Wiki blackhole at torproject.org
Wed Aug 7 06:11:06 UTC 2013


#9376: subprocess management module for pyptlib
---------------------------------+------------------------------------------
 Reporter:  infinity0            |          Owner:  asn           
     Type:  enhancement          |         Status:  needs_revision
 Priority:  normal               |      Milestone:                
Component:  Pluggable transport  |        Version:                
 Keywords:  pyptlib              |         Parent:                
   Points:                       |   Actualpoints:                
---------------------------------+------------------------------------------

Comment(by infinity0):

 Just tested catching signal.CTRL_BREAK_EVENT on windows python and it
 works fine, as long as you set creationflags=CREATE_NEW_PROCESS_GROUP (see
 [1] and [2]). You send the signal with os.kill(pid,
 signal.CTRL_BREAK_EVENT) and handle the signal with
 signal.signal(signal.SIGBREAK, handler).

 I'd suggest we amend the PT spec to explicitly say "Tor will try to
 shutdown a PT by sending it SIGTERM (UNIX) or CTRL_BREAK_EVENT (windows)"
 and add cross-platform method to this python module - e.g.
 pt_request_terminate() to send SIGTERM/SIGBREAK and pt_handle_terminate()
 to trap it.

 If python fix that CTRL-C handling bug, we can extend this to the 2-INT
 (UNIX) / 2-CTRL-C (windows) shutdown.

 @rransom: your option sounds like it would require the child to poll the
 parent and do cleanup itself, is that correct? I don't think that is a
 good design (despite the fact that Tor itself supports it) - it's not
 feasible for us to expect all child processes to implement this behaviour
 (you might want to Popen non-PT 3rd-party processes e.g. socat) and it
 involves unnecessarily ownership transferral (ownership of the child
 passes from the parent to the child itself) which adds complexity.

 [1]
 http://docs.python.org/2/library/subprocess.html#subprocess.CREATE_NEW_PROCESS_GROUP
 [2] http://bugs.python.org/issue9524

-- 
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/9376#comment:8>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list