-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest3.py
41 lines (34 loc) · 1.13 KB
/
test3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python3
""" tiny utility to kill all arangodb related processes """
import logging
import psutil
import signal
import os
import time
def handler(signum, frame):
#print("Xsignal!")
#if signum == signal.SIGINT:
# print('xSignal SIGINT received')
#if signum == signal.SIGBREAK:
# print('xSignal CTRL_BREAK_EVENT received')
#if signum == signal.CTRL_C_EVENT:
# print('xSignal signal.CTRL_C_EVENT received')
return
print("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
print(os.getpid())
signal.signal(signal.SIGINT, handler)
signal.signal(signal.SIGBREAK, handler)
process = psutil.Popen(['C:/tmp/PROG/usr/bin/arangodb','--starter.data-dir=\\tmp\\a', '--starter.mode', 'single'])
pid = process.pid
# process.send_signal(signal.CTRL_BREAK_EVENT)
print(pid)
print( os.getpid())
time.sleep(10)
os.kill(pid, signal.CTRL_C_EVENT)
print("snaotehu")
time.sleep(5)
for proc in psutil.process_iter(['pid', 'name']):
print("snatoehu %s" % str(proc))
if proc.pid == pid:
logging.info("found process after killing: %s", str(proc))
proc.wait()