Python win32process 模块,TerminateProcess() 实例源码

我们从Python开源项目中,提取了以下13个代码示例,用于说明如何使用win32process.TerminateProcess()

项目:aquests    作者:hansroh    | 项目源码 | 文件源码
def execute (cmd, timeout = 0):
        if timeout == 0:
            timeout = win32event.INFINITE

        info  = win32process.CreateProcess(None, cmd, None, None, 0, 0, None, None, win32process.STARTUPINFO())
        subprocess = info [0]

        rc = win32event.WaitForSingleObject (subprocess, timeout)           

        if rc == win32event.WAIT_FAILED:    
            return -1

        if rc == win32event.WAIT_TIMEOUT:
            try:
                win32process.TerminateProcess (subprocess, 0)                   
            except pywintypes.error:
                return -3
            return -2

        if rc == win32event.WAIT_OBJECT_0:
            return win32process.GetExitCodeProcess(subprocess)
项目:aquests    作者:hansroh    | 项目源码 | 文件源码
def timeout_execute (cmd, timeout = 0):
        if timeout == 0:
            timeout = win32event.INFINITE

        info  = win32process.CreateProcess(None, cmd, None, None, 0, 0, None, None, win32process.STARTUPINFO())
        subprocess = info [0]

        rc = win32event.WaitForSingleObject (subprocess, timeout)           

        if rc == win32event.WAIT_FAILED:    
            return -1

        if rc == win32event.WAIT_TIMEOUT:
            try:
                win32process.TerminateProcess (subprocess, 0)                   
            except pywintypes.error:
                return -3
            return -2

        if rc == win32event.WAIT_OBJECT_0:
            return win32process.GetExitCodeProcess(subprocess)
项目:hostapd-mana    作者:adde88    | 项目源码 | 文件源码
def signalProcess(self, signalID):
        if signalID in ("INT", "TERM", "KILL"):
            win32process.TerminateProcess(self.hProcess, 1)
项目:hostapd-mana    作者:adde88    | 项目源码 | 文件源码
def signalProcess(self, signalID):
        if signalID in ("INT", "TERM", "KILL"):
            win32process.TerminateProcess(self.hProcess, 1)
项目:sslstrip-hsts-openwrt    作者:adde88    | 项目源码 | 文件源码
def signalProcess(self, signalID):
        if signalID in ("INT", "TERM", "KILL"):
            win32process.TerminateProcess(self.hProcess, 1)
项目:sslstrip-hsts-openwrt    作者:adde88    | 项目源码 | 文件源码
def signalProcess(self, signalID):
        if signalID in ("INT", "TERM", "KILL"):
            win32process.TerminateProcess(self.hProcess, 1)
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def kill(self, gracePeriod=5000):
        """
        Kill process. Try for an orderly shutdown via WM_CLOSE.  If
        still running after gracePeriod (5 sec. default), terminate.
        """
        win32gui.EnumWindows(self.__close__, 0)
        if self.wait(gracePeriod) != win32event.WAIT_OBJECT_0:
            win32process.TerminateProcess(self.hProcess, 0)
            win32api.Sleep(100) # wait for resources to be released
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def kill(self, gracePeriod=5000):
        """
        Kill process. Try for an orderly shutdown via WM_CLOSE.  If
        still running after gracePeriod (5 sec. default), terminate.
        """
        win32gui.EnumWindows(self.__close__, 0)
        if self.wait(gracePeriod) != win32event.WAIT_OBJECT_0:
            win32process.TerminateProcess(self.hProcess, 0)
            win32api.Sleep(100) # wait for resources to be released
项目:Chromium_DepotTools    作者:p07r0457    | 项目源码 | 文件源码
def kill_win(process):
  """Kills a process with its windows handle.

  Has no effect on other platforms.
  """
  try:
    # Unable to import 'module'
    # pylint: disable=import-error
    import win32process
    # Access to a protected member _handle of a client class
    # pylint: disable=protected-access
    return win32process.TerminateProcess(process._handle, -1)
  except ImportError:
    pass
项目:node-gn    作者:Shouqun    | 项目源码 | 文件源码
def kill_win(process):
  """Kills a process with its windows handle.

  Has no effect on other platforms.
  """
  try:
    # Unable to import 'module'
    # pylint: disable=import-error
    import win32process
    # Access to a protected member _handle of a client class
    # pylint: disable=protected-access
    return win32process.TerminateProcess(process._handle, -1)
  except ImportError:
    pass
项目:zenchmarks    作者:squeaky-pl    | 项目源码 | 文件源码
def signalProcess(self, signalID):
        if self.pid is None:
            raise error.ProcessExitedAlready()
        if signalID in ("INT", "TERM", "KILL"):
            win32process.TerminateProcess(self.hProcess, 1)
项目:autoops_for_win    作者:qiueer    | 项目源码 | 文件源码
def TerminateProc(cls, whd):
        win32process.TerminateProcess(whd,0)
项目:depot_tools    作者:webrtc-uwp    | 项目源码 | 文件源码
def kill_win(process):
  """Kills a process with its windows handle.

  Has no effect on other platforms.
  """
  try:
    # Unable to import 'module'
    # pylint: disable=import-error
    import win32process
    # Access to a protected member _handle of a client class
    # pylint: disable=protected-access
    return win32process.TerminateProcess(process._handle, -1)
  except ImportError:
    pass