Esempio n. 1
0
def kill_managed_process(name):
    if name not in running or name not in managed_processes:
        return
    cloudlog.info("killing %s" % name)

    if running[name].exitcode is None:
        if name in interrupt_processes:
            os.kill(running[name].pid, signal.SIGINT)
        elif name in kill_processes:
            os.kill(running[name].pid, signal.SIGKILL)
        else:
            running[name].terminate()

        join_process(running[name], 5)

        if running[name].exitcode is None:
            if name in unkillable_processes:
                cloudlog.critical(
                    "unkillable process %s failed to exit! rebooting in 15 if it doesn't die"
                    % name)
                join_process(running[name], 15)
                if running[name].exitcode is None:
                    cloudlog.critical("FORCE REBOOTING PHONE!")
                    os.system("date >> /sdcard/unkillable_reboot")
                    os.system("reboot")
                    raise RuntimeError
            else:
                cloudlog.info("killing %s with SIGKILL" % name)
                os.kill(running[name].pid, signal.SIGKILL)
                running[name].join()

    cloudlog.info("%s is dead with %d" % (name, running[name].exitcode))
    del running[name]
Esempio n. 2
0
def kill_managed_process(name):
    if name not in running or name not in managed_processes:
        return
    cloudlog.info("killing %s" % name)

    if running[name].exitcode is None:
        if name in interrupt_processes:
            os.kill(running[name].pid, signal.SIGINT)
        else:
            running[name].terminate()

        # give it 5 seconds to die
        running[name].join(5.0)
        if running[name].exitcode is None:
            if name in unkillable_processes:
                cloudlog.critical(
                    "unkillable process %s failed to exit! rebooting in 15 if it doesn't die"
                    % name)
                running[name].join(15.0)
                if running[name].exitcode is None:
                    cloudlog.critical("would have FORCE REBOOTed PHONE!")
                    raise RuntimeError
            else:
                cloudlog.info("killing %s with SIGKILL" % name)
                os.kill(running[name].pid, signal.SIGKILL)
                running[name].join()

    cloudlog.info("%s is dead with %d" % (name, running[name].exitcode))
    del running[name]
Esempio n. 3
0
def kill_managed_process(name, retry=True):
  if name not in running or name not in managed_processes:
    return
  cloudlog.info(f"killing {name}")

  if running[name].exitcode is None:
    sig = signal.SIGKILL if name in kill_processes else signal.SIGINT
    os.kill(running[name].pid, sig)

    join_process(running[name], 5)

    if running[name].exitcode is None:
      if not retry:
        raise Exception(f"{name} failed to die")

      if name in unkillable_processes:
        cloudlog.critical("unkillable process %s failed to exit! rebooting in 15 if it doesn't die" % name)
        join_process(running[name], 15)
        if running[name].exitcode is None:
          cloudlog.critical("unkillable process %s failed to die!" % name)
          os.system("date >> /data/unkillable_reboot")
          os.sync()
          HARDWARE.reboot()
          raise RuntimeError
      else:
        cloudlog.info("killing %s with SIGKILL" % name)
        os.kill(running[name].pid, signal.SIGKILL)
        running[name].join()

  ret = running[name].exitcode
  cloudlog.info(f"{name} is dead with {ret}")
  del running[name]
  return ret
Esempio n. 4
0
 def terminate(signalNumber, frame):
   print('got SIGTERM, exiting..')
   should_exit = True
   send_dmon_packet(pm, [is_rhd, is_rhd_checked, not should_exit])
   proc_cam.send_signal(signal.SIGINT)
   proc_mon.send_signal(signal.SIGINT)
   kill_start = time.time()
   while proc_cam.poll() is None:
     if time.time() - kill_start > KILL_TIMEOUT:
       from selfdrive.swaglog import cloudlog
       cloudlog.critical("FORCE REBOOTING PHONE!")
       os.system("date >> /sdcard/unkillable_reboot")
       os.system("reboot")
       raise RuntimeError
     continue
   controls_sender.terminate()
   exit()
Esempio n. 5
0
    def stop(self, retry=True, block=True):
        if self.proc is None:
            return

        if self.proc.exitcode is None:
            if not self.shutting_down:
                cloudlog.info(f"killing {self.name}")
                sig = signal.SIGKILL if self.sigkill else signal.SIGINT
                self.signal(sig)
                self.shutting_down = True

                if not block:
                    return

            join_process(self.proc, 5)

            # If process failed to die send SIGKILL or reboot
            if self.proc.exitcode is None and retry:
                if self.unkillable:
                    cloudlog.critical(
                        f"unkillable process {self.name} failed to exit! rebooting in 15 if it doesn't die"
                    )
                    join_process(self.proc, 15)

                    if self.proc.exitcode is None:
                        cloudlog.critical(
                            f"unkillable process {self.name} failed to die!")
                        os.system("date >> /data/unkillable_reboot")
                        os.sync()
                        HARDWARE.reboot()
                        raise RuntimeError
                else:
                    cloudlog.info(f"killing {self.name} with SIGKILL")
                    self.signal(signal.SIGKILL)
                    self.proc.join()

        ret = self.proc.exitcode
        cloudlog.info(f"{self.name} is dead with {ret}")

        if self.proc.exitcode is not None:
            self.shutting_down = False
            self.proc = None

        return ret
Esempio n. 6
0
def kill_managed_process(name):
    if name not in running or name not in managed_processes:
        return
    cloudlog.info("killing %s" % name)

    if running[name].exitcode is None:
        if name in interrupt_processes:
            os.kill(running[name].pid, signal.SIGINT)
        elif name in kill_processes:
            os.kill(running[name].pid, signal.SIGKILL)
        else:
            running[name].terminate()

        # Process().join(timeout) will hang due to a python 3 bug: https://bugs.python.org/issue28382
        # We have to poll the exitcode instead
        # running[name].join(5.0)

        t = time.time()
        while time.time() - t < 5 and running[name].exitcode is None:
            time.sleep(0.001)

        if running[name].exitcode is None:
            if name in unkillable_processes:
                cloudlog.critical(
                    "unkillable process %s failed to exit! rebooting in 15 if it doesn't die"
                    % name)
                running[name].join(15.0)
                if running[name].exitcode is None:
                    cloudlog.critical("FORCE REBOOTING PHONE!")
                    os.system("date >> /sdcard/unkillable_reboot")
                    os.system("reboot")
                    raise RuntimeError
            else:
                cloudlog.info("killing %s with SIGKILL" % name)
                os.kill(running[name].pid, signal.SIGKILL)
                running[name].join()

    cloudlog.info("%s is dead with %d" % (name, running[name].exitcode))
    del running[name]