[tor-commits] [stem/master] Extra spaces were inserted into process names via set_process_name()

atagar at torproject.org atagar at torproject.org
Fri Apr 19 16:35:40 UTC 2013


commit 8adc55c0139ff9f0925541be1254bea4767716ed
Author: Tomasz Kunikowski <tomasz.kunikowski at gmail.com>
Date:   Thu Apr 18 23:54:25 2013 +0200

    Extra spaces were inserted into process names via set_process_name()
    
    After running set_process_name() ps would report spaces within our process
    name. For instance, when running our integ tests our name would become...
    
    p   y   t   h   o   n       .   /   r   u   n   _   t   e   s
    
    Fixed thanks to ragwater, who figured out that ctypes.memmove() wanted unicode
    rather than byte content...
    
    https://trac.torproject.org/8631
---
 stem/util/system.py |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/stem/util/system.py b/stem/util/system.py
index 0a94b57..bea6222 100644
--- a/stem/util/system.py
+++ b/stem/util/system.py
@@ -799,7 +799,8 @@ def _set_argv(process_name):
   zero_size = max(len(current_name), len(process_name))
 
   ctypes.memset(argc.contents, 0, zero_size + 1)  # null terminate the string's end
-  ctypes.memmove(argc.contents, process_name, len(process_name))
+  process_name_encoded = process_name.encode('utf8')
+  ctypes.memmove(argc.contents, process_name_encoded, len(process_name))
   _PROCESS_NAME = process_name
 
 



More information about the tor-commits mailing list