Exemplo n.º 1
0
def kill_process_by_name(name):
    """Find and kill all processes containing a certain name"""

    pids = get_pids(name)

    if os.name == "nt" or sys.platform == "cygwin":
        for p in pids:
            import wpk

            wpk.kill_pid(p)

    else:
        for pid in pids:
            try:
                os.kill(pid, signal.SIGTERM)
            except OSError:
                pass
            sleep(0.5)
            if len(get_pids(name)) is not 0:
                try:
                    os.kill(pid, signal.SIGKILL)
                except OSError:
                    pass
                sleep(0.5)
                if len(get_pids(name)) is not 0:
                    logger.error("Could not kill process")
Exemplo n.º 2
0
def kill_process_by_name(name):
    """Find and kill all processes containing a certain name"""

    pids = get_pids(name)

    if os.name == 'nt' or sys.platform == 'cygwin':
        for p in pids:
            import wpk

            wpk.kill_pid(p)

    else:
        for pid in pids:

            try:
                os.kill(pid, signal.SIGTERM)
            except OSError:
                pass
            sleep(.5)
            if len(get_pids(name)) is not 0:
                try:
                    os.kill(pid, signal.SIGKILL)
                except OSError:
                    pass
                sleep(.5)
                if len(get_pids(name)) is not 0:
                    logger.error('Could not kill process')
Exemplo n.º 3
0
def kill_process_by_name(name):
    """Find and kill all processes containing a certain name"""
    # XXX https://bugzilla.mozilla.org/show_bug.cgi?id=592750

    pids = get_pids(name)

    if os.name == 'nt' or sys.platform == 'cygwin':
        for p in pids:
            import wpk
            wpk.kill_pid(p)

    else:
        for pid in pids:
            try:
                os.kill(pid, signal.SIGTERM)
            except OSError: pass
            sleep(.5)
            if len(get_pids(name)) is not 0:
                try:
                    os.kill(pid, signal.SIGKILL)
                except OSError: pass
                sleep(.5)
                if len(get_pids(name)) is not 0:
                    raise Exception('Could not kill process')