Remove the need for kill for frida-ps

This commit is contained in:
Asger Hautop Drewsen
2015-06-03 21:41:58 +02:00
parent f37ec87b2c
commit 5bc8c51a1e
2 changed files with 32 additions and 10 deletions
+31 -9
View File
@@ -7,20 +7,44 @@ import platform
import sys
import threading
import time
from select import select
import colorama
from colorama import Style
import frida
if platform.system() == 'Windows':
import msvcrt
def await_enter():
try:
if sys.version_info[0] >= 3:
input()
def input_with_timeout(timeout):
if platform.system() == 'Windows':
start_time = time.time()
s = ''
while True:
while msvcrt.kbhit():
c = msvcrt.getche()
if ord(c) == 13: # enter_key
break
elif ord(c) >= 32: #space_char
s += c
if time.time() - start_time > timeout:
return None
return s
else:
rlist, _, _ = select([sys.stdin], [], [], timeout)
if rlist:
return sys.stdin.readline()
else:
raw_input()
except (KeyboardInterrupt, EOFError):
return None
def await_enter(reactor):
try:
while input_with_timeout(0.5) == None:
if not reactor._running:
break
except KeyboardInterrupt:
print('')
pass
@@ -134,8 +158,6 @@ class ConsoleApplication(object):
def _exit(self, exit_status):
self._exit_status = exit_status
# FIXME:
os.system('kill {}'.format(os.getpid()))
self._reactor.stop()
def _try_start(self):
@@ -243,7 +265,7 @@ class Reactor(object):
watcher_thread.daemon = True
watcher_thread.start()
self._run_until_return()
self._run_until_return(self)
self.stop()
def _run(self):
+1 -1
View File
@@ -76,7 +76,7 @@ def main():
pass
self._script = None
def _process_input(self):
def _process_input(self, reactor):
self._print_startup_message()
self._ready.wait()