VirtualBox

Ignore:
Timestamp:
Nov 4, 2017 10:19:34 AM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
118928
Message:

better processExists() implementations for windows.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/testdriver/winbase.py

    r69546 r69578  
    4141import win32event;          # pylint: disable=import-error
    4242import win32process;        # pylint: disable=import-error
     43import winerror;            # pylint: disable=import-error
     44import pywintypes;          # pylint: disable=import-error
    4345
    4446# Validation Kit imports.
     
    112114def processExists(uPid):
    113115    """ The Windows version of base.processExists """
    114     # pylint: disable=no-member
    115     fRc = False;
    116     try:
    117         hProcess = win32api.OpenProcess(win32con.PROCESS_QUERY_INFORMATION, False, uPid);
    118     except:
     116    # We try open the process for waiting since this is generally only forbidden in a very few cases.
     117    try:
     118        hProcess = win32api.OpenProcess(win32con.SYNCHRONIZE, False, uPid);     # pylint: disable=no-member
     119    except pywintypes.error as oXcpt:                                           # pylint: disable=no-member
     120        if oXcpt.winerror == winerror.ERROR_INVALID_PARAMETER:
     121            return False;
     122        if oXcpt.winerror != winerror.ERROR_ACCESS_DENIED:
     123            reporter.logXcpt('uPid=%s oXcpt=%s' % (uPid, oXcpt));
     124            return False;
     125        reporter.logXcpt('uPid=%s oXcpt=%s' % (uPid, oXcpt));
     126    except Exception as oXcpt:
    119127        reporter.logXcpt('uPid=%s' % (uPid,));
     128        return False;
    120129    else:
    121130        hProcess.Close(); #win32api.CloseHandle(hProcess)
    122         fRc = True;
    123     return fRc;
     131    return True;
    124132
    125133def processCheckPidAndName(uPid, sName):
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette