Skip to content

Commit c54fe08

Browse files
committed
double wait does not work, blocking in signal handler not good, exit on do_exit, change to SIGINT, use existing stop to support ctrl+c
nope
1 parent 40c8c66 commit c54fe08

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

selfdrive/pandad/pandad.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,21 @@ def main() -> NoReturn:
6767
# signal pandad to close the relay and exit
6868
def signal_handler(signum, frame):
6969
cloudlog.info(f"Caught signal {signum}, exiting")
70-
if process is not None and process.poll() is None:
71-
process.terminate()
72-
process.wait()
73-
sys.exit(1)
70+
nonlocal do_exit
71+
do_exit = True
72+
if process is not None:
73+
process.send_signal(signal.SIGINT)
7474

7575
process = None
76-
signal.signal(signal.SIGTERM, signal_handler)
76+
signal.signal(signal.SIGINT, signal_handler)
7777

7878
count = 0
79+
do_exit = False
7980
first_run = True
8081
params = Params()
8182
no_internal_panda_count = 0
8283

83-
while True:
84+
while not do_exit:
8485
try:
8586
count += 1
8687
cloudlog.event("pandad.flash_and_connect", count=count)

system/manager/manager.py

-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import os
44
import signal
55
import sys
6-
import time
76
import traceback
87

98
from cereal import log
@@ -172,10 +171,6 @@ def manager_thread() -> None:
172171
cloudlog.warning(f"Shutting down manager - {param} set")
173172

174173
if shutdown:
175-
# Signal processes to shut down with a small grace period
176-
for p in managed_processes.values():
177-
p.signal(signal.SIGTERM)
178-
time.sleep(1)
179174
break
180175

181176

0 commit comments

Comments
 (0)