<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def watch_process(self, process):
 """ Manages the status of a single process """


        status = process["psutil"].status()

        # TODO: how to avoid zombies?
        # print process["pid"], status

        if process.get("terminate"):
            if status in ("zombie", "dead"):
                process["dead"] = True
            elif process.get("terminate_at"):
                if time.time() > (process["terminate_at"] + 5):
                    log.warning("Process %s had to be sent SIGKILL" % (process["pid"], ))
                    process["subprocess"].send_signal(signal.SIGKILL)
                elif time.time() > process["terminate_at"]:
                    log.warning("Process %s had to be sent SIGTERM" % (process["pid"], ))
                    process["subprocess"].send_signal(signal.SIGTERM)

        else:
            if status in ("zombie", "dead"):
                # Restart a new process right away (TODO: sleep a bit? max retries?)
                process["dead"] = True
                self.spawn(process["command"])

            elif status not in ("running", "sleeping"):
                log.warning("Process %s was in status %s" % (process["pid"], status))