diff --git a/pyrasite/injector.py b/pyrasite/injector.py index 067fad1..b1832da 100644 --- a/pyrasite/injector.py +++ b/pyrasite/injector.py @@ -23,18 +23,18 @@ def inject(pid, filename, verbose=False, gdb_prefix=''): """Executes a file in a running Python process.""" filename = os.path.abspath(filename) gdb_cmds = [ - 'PyGILState_Ensure()', - 'PyRun_SimpleString("' + '((int (*)())PyGILState_Ensure)()', + '((int (*)(const char *))PyRun_SimpleString)("' 'import sys; sys.path.insert(0, \\"%s\\"); ' 'sys.path.insert(0, \\"%s\\"); ' 'exec(open(\\"%s\\").read())")' % (os.path.dirname(filename), os.path.abspath(os.path.join(os.path.dirname(__file__), '..')), filename), - 'PyGILState_Release($1)', + '((void (*) (int) )PyGILState_Release)($1)', ] - p = subprocess.Popen('%sgdb -p %d -batch %s' % (gdb_prefix, pid, - ' '.join(["-eval-command='call %s'" % cmd for cmd in gdb_cmds])), + cmd = '%sgdb -p %d -batch %s' % (gdb_prefix, pid, ' '.join(["-eval-command='call %s'" % cmd for cmd in gdb_cmds])) + p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate() if verbose: @@ -56,4 +56,4 @@ def inject_win(pid, filename, verbose=False, gdb_prefix=''): print(out) print(err) - inject = inject_win \ No newline at end of file + inject = inject_win