  
  def downloader_loop(event):
    if os.path.exists(ASSIST_DATA_FILE):
      os.remove(ASSIST_DATA_FILE)
    while not os.path.exists(ASSIST_DATA_FILE) and not event.is_set():
      download_assistance()
      time.sleep(10)
  
  def inject_assistance():
    for _ in range(5):
      try:
        cmd = f"mmcli -m any --timeout 30 --location-inject-assistance-data={ASSIST_DATA_FILE}"
 
</s> remove   signal.signal(signal.SIGINT, lambda sig, frame: cleanup(assist_fetch_proc))
  signal.signal(signal.SIGTERM, lambda sig, frame: cleanup(assist_fetch_proc))
 </s> add   signal.signal(signal.SIGINT, cleanup)
  signal.signal(signal.SIGTERM, cleanup) </s> remove   def cleanup(proc):
 </s> add   def cleanup(sig, frame):
  try:
    while not os.path.exists(ASSIST_DATA_FILE) and not event.is_set():
      download_assistance()
      event.wait(timeout=10)
  except KeyboardInterrupt:
    pass
  
  def downloader_loop(event):
    if os.path.exists(ASSIST_DATA_FILE):
      os.remove(ASSIST_DATA_FILE)
  try:
    while not os.path.exists(ASSIST_DATA_FILE) and not event.is_set():
      download_assistance()
      event.wait(timeout=10)
  except KeyboardInterrupt:
    pass
  try:
    while not os.path.exists(ASSIST_DATA_FILE) and not event.is_set():
      download_assistance()
      event.wait(timeout=10)
  except KeyboardInterrupt:
    pass
  try:
    while not os.path.exists(ASSIST_DATA_FILE) and not event.is_set():
      download_assistance()
      event.wait(timeout=10)
  except KeyboardInterrupt:
    pass
  
  def inject_assistance():
    for _ in range(5):
      try:
        cmd = f"mmcli -m any --timeout 30 --location-inject-assistance-data={ASSIST_DATA_FILE}"
keep keep keep keep replace replace replace keep keep keep keep keep
 rawgpsd: better download proc cleanup (#29199)

* rawgpsd: better download proc cleanup

* more

* cleanup

---------

Co-authored-by: Comma Device <device@comma.ai> 
system/sensord/rawgps/rawgpsd.py