當前位置: 首頁>>代碼示例>>Python>>正文


Python win32con.PROCESS_TERMINATE屬性代碼示例

本文整理匯總了Python中win32con.PROCESS_TERMINATE屬性的典型用法代碼示例。如果您正苦於以下問題:Python win32con.PROCESS_TERMINATE屬性的具體用法?Python win32con.PROCESS_TERMINATE怎麽用?Python win32con.PROCESS_TERMINATE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在win32con的用法示例。


在下文中一共展示了win32con.PROCESS_TERMINATE屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import win32con [as 別名]
# 或者: from win32con import PROCESS_TERMINATE [as 別名]
def __init__(self, *args, **kwargs):
        kwargs = dict(_Popen_defaults + kwargs.items())
        if 'creationflagsmerge' in kwargs:
            kwargs['creationflags'] = (
                kwargs.get('creationflags', 0) | kwargs['creationflagsmerge'])
            del kwargs['creationflagsmerge']
        for f in ['stdout', 'stderr']:
            if kwargs[f] is SINK:
                kwargs[f] = create_sink()
        # super() does some magic that makes **kwargs not work, so just call
        # our super-constructor directly
        subprocess.Popen.__init__(self, *args, **kwargs)
        _CHILD_PROCS.append(self)

        if mswindows and _kill_children_on_death:
            handle = windll.kernel32.OpenProcess(
                win32con.SYNCHRONIZE | win32con.PROCESS_SET_QUOTA | win32con.PROCESS_TERMINATE, 0, self.pid)
            if win32job.AssignProcessToJobObject(_chJob, handle) == 0:
                raise WinError()

    # TODO(infinity0): perhaps replace Popen.std* with wrapped file objects
    # that don't buffer readlines() et. al. Currently one must avoid these and
    # use while/readline(); see man page for "python -u" for more details. 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:25,代碼來源:subproc.py

示例2: SvcDoRun

# 需要導入模塊: import win32con [as 別名]
# 或者: from win32con import PROCESS_TERMINATE [as 別名]
def SvcDoRun(self):
        import servicemanager
        servicemanager.LogInfoMsg(self._svc_name_ + " Start Requested")
        try:
            hJob = win32job.CreateJobObject(None, "")
            extended_info = win32job.QueryInformationJobObject(hJob, win32job.JobObjectExtendedLimitInformation)
            extended_info['BasicLimitInformation']['LimitFlags'] = win32job.JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE
            win32job.SetInformationJobObject(hJob, win32job.JobObjectExtendedLimitInformation, extended_info)
            command = "resilient-circuits.exe run " + self._resilient_args_
            command_args = shlex.split(command)
            self.process_handle = subprocess.Popen(command_args)
            # Convert process id to process handle:
            perms = win32con.PROCESS_TERMINATE | win32con.PROCESS_SET_QUOTA
            hProcess = win32api.OpenProcess(perms, False, self.process_handle.pid)
            win32job.AssignProcessToJobObject(hJob, hProcess)
        except:
            servicemanager.LogErrorMsg(self._svc_name_ + " failed to launch resilient-circuits.exe")
            raise
        servicemanager.LogInfoMsg(self._svc_name_ + " Started")

        while self.isAlive:
            if self.process_handle.poll() != None:
                self.SvcStop()
            win32api.SleepEx(10000, True) 
開發者ID:ibmresilient,項目名稱:resilient-python-api,代碼行數:26,代碼來源:service_wrapper.py

示例3: killProcName

# 需要導入模塊: import win32con [as 別名]
# 或者: from win32con import PROCESS_TERMINATE [as 別名]
def killProcName(procname):
	# Change suggested by Dan Knierim, who found that this performed a
	# "refresh", allowing us to kill processes created since this was run
	# for the first time.
	try:
		win32pdhutil.GetPerformanceAttributes('Process','ID Process',procname)
	except:
		pass

	pids = win32pdhutil.FindPerformanceAttributesByName(procname)

	# If _my_ pid in there, remove it!
	try:
		pids.remove(win32api.GetCurrentProcessId())
	except ValueError:
		pass

	if len(pids)==0:
		result = "Can't find %s" % procname
	elif len(pids)>1:
		result = "Found too many %s's - pids=`%s`" % (procname,pids)
	else:
		handle = win32api.OpenProcess(win32con.PROCESS_TERMINATE, 0,pids[0])
		win32api.TerminateProcess(handle,0)
		win32api.CloseHandle(handle)
		result = ""

	return result 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:30,代碼來源:killProcName.py

示例4: kill

# 需要導入模塊: import win32con [as 別名]
# 或者: from win32con import PROCESS_TERMINATE [as 別名]
def kill(self):
        handle = win32api.OpenProcess(
            win32con.PROCESS_VM_READ | win32con.PROCESS_TERMINATE, pywintypes.FALSE, self.childpid)
        win32process.TerminateProcess(handle, 3) 
開發者ID:kdart,項目名稱:pycopia,代碼行數:6,代碼來源:WindowsServer.py

示例5: kill_process

# 需要導入模塊: import win32con [as 別名]
# 或者: from win32con import PROCESS_TERMINATE [as 別名]
def kill_process(name):
    
    for pid in win32process.EnumProcesses():
        
        # do try not to kill yourself
        if pid == win32api.GetCurrentProcessId():
            continue
        
        try:
            p = win32api.OpenProcess(win32con.PROCESS_QUERY_INFORMATION
                                     | win32con.PROCESS_VM_READ
                                     | win32con.PROCESS_TERMINATE,
                                     False, pid)
        except:
            continue

        if not p:
            continue
        
        try:
            hl = win32process.EnumProcessModules(p)
        except:
            win32api.CloseHandle(p)
            continue

        h = hl[0]
        pname = win32process.GetModuleFileNameEx(p, h)
        root, pname = os.path.split(pname)
        #print name, pname
        if compare(name, pname):
            #print "KILL", pname
            win32api.TerminateProcess(p, 0)
            win32api.CloseHandle(p)
            return True

        win32api.CloseHandle(p)
    return False 
開發者ID:kenorb-contrib,項目名稱:BitTorrent,代碼行數:39,代碼來源:pykill.py


注:本文中的win32con.PROCESS_TERMINATE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。