Commit 1ba96316 by 周田

feat:linux下正常关闭子进程

parent 462b2eed
......@@ -28,7 +28,8 @@ def start_signal_callback(sender, **kwargs):
process = subprocess.Popen(['python',
f'./simulate_device_manager/simulate_devices/{protocol_name}.py',
f'{device_port}'])
f'{device_port}'],
preexec_fn=os.setsid)
SIMULATE_DEVICE_PROCESS[device_name] = process
......@@ -43,7 +44,6 @@ def stop_signal_callback(sender, **kwargs):
assert device_name is not None, 'device_name is None'
process = SIMULATE_DEVICE_PROCESS.get(device_name)
process.terminate()
process.wait()
os.kill(process.pid, signal.SIGTERM)
if process.poll() is None:
os.killpg(process.pid, signal.SIGTERM)
del SIMULATE_DEVICE_PROCESS[device_name]
......@@ -6,15 +6,10 @@ import re
import threading
import datetime
import sys
import configparser
config = configparser.ConfigParser() # 类实例化
# 定义ini文件路径 这个文件用于存放 天控器当前的报警状态
path = r'acu7m5_hyds.ini'
path = r'./simulate_device_manager/simulate_devices/acu7m5_hyds.ini'
argv = sys.argv[1:]
tcp_port =int(argv[0])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment