def get_running_jobs(db):
    """
    Retrieves and manages running jobs from the database.

    This function fetches the list of running jobs from the provided database object.
    For each running job, it checks the process status. If the status is "completed",
    "error", or "zombie", it attempts to kill the process and remove the job from the
    database. After processing, it fetches and returns the updated list of running jobs.

    Args:
        db: A database object that provides methods to get and delete running jobs.

    Returns:
        list: An updated list of running jobs from the database.
    """
    running_jobs = db.get_running_jobs()
    if running_jobs:
        for _pid in running_jobs:
            proc_status = get_process_status(_pid)
            proc_status = proc_status.strip().lower()
            if proc_status in ("completed", "error", "zombie"):
                logger.info(f"Killing PID: {_pid}")
                try:
                    kill_process_by_pid(_pid)
                except Exception as e:
                    logger.info(f"Error while killing process: {e}")
                    logger.info(f"Process {_pid} is already completed. Skipping...")
                db.delete_job(_pid)

    running_jobs = db.get_running_jobs()
    return running_jobs

    Retrieves and manages running jobs from the database.

    This function fetches the list of running jobs from the provided database object.
    For each running job, it checks the process status. If the status is "completed",
    "error", or "zombie", it attempts to kill the process and remove the job from the
    database. After processing, it fetches and returns the updated list of running jobs.

    Args:
        db: A database object that provides methods to get and delete running jobs.

    Returns:
        list: An updated list of running jobs from the database.
    
src/autotrain/app/utils.py