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/common/utils.py

    r69573 r69578  
    5151    import win32file;           # pylint: disable=import-error
    5252    import win32process;        # pylint: disable=import-error
     53    import winerror;            # pylint: disable=import-error
     54    import pywintypes;          # pylint: disable=import-error
    5355else:
    5456    import signal;
     
    783785    if sys.platform == 'win32':
    784786        fRc = False;
     787        # We try open the process for waiting since this is generally only forbidden in a very few cases.
    785788        try:
    786             hProcess = win32api.OpenProcess(win32con.PROCESS_QUERY_INFORMATION, False, uPid);   # pylint: disable=no-member
    787         except:
     789            hProcess = win32api.OpenProcess(win32con.SYNCHRONIZE, False, uPid);     # pylint: disable=no-member
     790        except pywintypes.error as oXcpt:                                           # pylint: disable=no-member
     791            if oXcpt.winerror == winerror.ERROR_ACCESS_DENIED:
     792                fRc = True;
     793        except Exception as oXcpt:
    788794            pass;
    789795        else:
    790             hProcess.Close(); # win32api.CloseHandle(hProcess);
     796            hProcess.Close();
    791797            fRc = True;
    792798    else:
     
    794800            os.kill(uPid, 0);
    795801            fRc = True;
    796         except:
     802        except: ## @todo check error code.
    797803            fRc = False;
    798804    return fRc;
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