third_party/blink/tools/blinkpy/common/system/executive.py
def kill_process(self, pid, kill_tree=True):
        """Attempts to kill the given pid.

        if kill_tree is True, the whole process group will be killed.

        Will fail silently if pid does not exist.
        """
        if sys.platform == 'win32':
            # Workaround for race condition that occurs when the browser is
            # killed as it's launching a process. This sometimes leaves a child
            # process that is in a suspended state.
            # Follow the Win32 API naming style. pylint: disable=invalid-name
            OpenProcess = ctypes.windll.kernel32.OpenProcess
            CloseHandle = ctypes.windll.kernel32.CloseHandle
            NtSuspendProcess = ctypes.windll.ntdll.NtSuspendProcess
            PROCESS_ALL_ACCESS = 0x1F0FFF
            process_handle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
            if process_handle != 0:
                NtSuspendProcess(process_handle)
                CloseHandle(process_handle)

            command = ['taskkill.exe', '/f']
            if kill_tree:
                command.append('/t')
            command += ['/pid', pid]
            # taskkill will exit 128 if the process is not found. We should log.
            self.run_command(command, error_handler=self.log_error)
            return

        try:
            if kill_tree:
                os.killpg(os.getpgid(pid), signal.SIGKILL)
            else:
                os.kill(pid, signal.SIGKILL)
            # At this point if no exception has been raised, the kill has
            # succeeded, so we can safely use a blocking wait.
            os.waitpid(pid, 0)
        except OSError as error:
            if error.errno == errno.ESRCH:
                _log.debug("PID %s does not exist.", pid)
                return
            if error.errno == errno.ECHILD:
                # Can't wait on a non-child process, but the kill worked.
                return
            if error.errno == errno.EPERM and \
                    kill_tree and sys.platform == 'darwin':
                # Calling killpg on a process group whose leader is defunct
                # causes a permission error on macOS, in which case we try to
                # collect the defunct process.
                if os.waitpid(pid, os.WNOHANG) == (0, 0):
                    return
            raise
Attempts to kill the given pid.

        if kill_tree is True, the whole process group will be killed.

        Will fail silently if pid does not exist.
        
Attempts to kill the given pid.
if kill_tree is True, the whole process group will be killed.

Will fail silently if pid does not exist.
Attempts to kill the given pid . if kill_tree is True the whole process group will be killed . Will fail silently if pid does not exist .
def kill_process(self, pid, kill_tree=True):
        if sys.platform == 'win32':
            OpenProcess = ctypes.windll.kernel32.OpenProcess
            CloseHandle = ctypes.windll.kernel32.CloseHandle
            NtSuspendProcess = ctypes.windll.ntdll.NtSuspendProcess
            PROCESS_ALL_ACCESS = 0x1F0FFF
            process_handle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
            if process_handle != 0:
                NtSuspendProcess(process_handle)
                CloseHandle(process_handle)
            command = ['taskkill.exe', '/f']
            if kill_tree:
                command.append('/t')
            command += ['/pid', pid]
            self.run_command(command, error_handler=self.log_error)
            return
        try:
            if kill_tree:
                os.killpg(os.getpgid(pid), signal.SIGKILL)
            else:
                os.kill(pid, signal.SIGKILL)
            os.waitpid(pid, 0)
        except OSError as error:
            if error.errno == errno.ESRCH:
                _log.debug("PID %s does not exist.", pid)
                return
            if error.errno == errno.ECHILD:
                return
            if error.errno == errno.EPERM and \
                    kill_tree and sys.platform == 'darwin':
                if os.waitpid(pid, os.WNOHANG) == (0, 0):
                    return
            raise
def kill_process ( self , pid , kill_tree = True ) : if sys . platform == 'win32' : OpenProcess = ctypes . windll . kernel32 . OpenProcess CloseHandle = ctypes . windll . kernel32 . CloseHandle NtSuspendProcess = ctypes . windll . ntdll . NtSuspendProcess PROCESS_ALL_ACCESS = 0x1F0FFF process_handle = OpenProcess ( PROCESS_ALL_ACCESS , False , pid ) if process_handle != 0 : NtSuspendProcess ( process_handle ) CloseHandle ( process_handle ) command = [ 'taskkill.exe' , '/f' ] if kill_tree : command . append ( '/t' ) command += [ '/pid' , pid ] self . run_command ( command , error_handler = self . log_error ) return try : if kill_tree : os . killpg ( os . getpgid ( pid ) , signal . SIGKILL ) else : os . kill ( pid , signal . SIGKILL ) os . waitpid ( pid , 0 ) except OSError as error : if error . errno == errno . ESRCH : _log . debug ( "PID %s does not exist." , pid ) return if error . errno == errno . ECHILD : return if error . errno == errno . EPERM and kill_tree and sys . platform == 'darwin' : if os . waitpid ( pid , os . WNOHANG ) == ( 0 , 0 ) : return raise
Attempts to kill the given pid.
Attempts to kill the given pid .
"""Attempts to kill the given pid.

        if kill_tree is True, the whole process group will be killed.

        Will fail silently if pid does not exist.
        """ # Workaround for race condition that occurs when the browser is # killed as it's launching a process. This sometimes leaves a child # process that is in a suspended state. # Follow the Win32 API naming style. pylint: disable=invalid-name # taskkill will exit 128 if the process is not found. We should log. # At this point if no exception has been raised, the kill has # succeeded, so we can safely use a blocking wait. # Can't wait on a non-child process, but the kill worked. # Calling killpg on a process group whose leader is defunct # causes a permission error on macOS, in which case we try to # collect the defunct process.
self
pid
kill_tree