VirtualBox

Ignore:
Timestamp:
Jan 9, 2017 11:07:28 AM (8 years ago)
Author:
vboxsync
Message:

common/utils.py,testboxscript,tdUnitTest1: Create separate windows (console) process groups for children so we can safely generate Ctrl-C signals without also committing suicide. (testdriver.base.spawn already did this)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/common/utils.py

    r65007 r65196  
    435435    return None;
    436436
     437def processPopenSafe(*aPositionalArgs, **dKeywordArgs):
     438    """
     439    Wrapper for subprocess.Popen that's Ctrl-C safe on windows.
     440    """
     441    if getHostOs() == 'win':
     442        if dKeywordArgs.get('creationflags', 0) == 0:
     443            dKeywordArgs['creationflags'] = subprocess.CREATE_NEW_PROCESS_GROUP;
     444    return subprocess.Popen(*aPositionalArgs, **dKeywordArgs);
     445
    437446def processCall(*aPositionalArgs, **dKeywordArgs):
    438447    """
    439     Wrapper around subprocess.call to deal with its absense in older
     448    Wrapper around subprocess.call to deal with its absence in older
    440449    python versions.
    441450    Returns process exit code (see subprocess.poll).
     
    444453    assert dKeywordArgs.get('stderr') is None;
    445454    _processFixPythonInterpreter(aPositionalArgs, dKeywordArgs);
    446     oProcess = subprocess.Popen(*aPositionalArgs, **dKeywordArgs);
     455    oProcess = processPopenSafe(*aPositionalArgs, **dKeywordArgs);
    447456    return oProcess.wait();
    448457
     
    453462    """
    454463    _processFixPythonInterpreter(aPositionalArgs, dKeywordArgs);
    455     oProcess = subprocess.Popen(stdout=subprocess.PIPE, *aPositionalArgs, **dKeywordArgs);
     464    oProcess = processPopenSafe(stdout=subprocess.PIPE, *aPositionalArgs, **dKeywordArgs);
    456465
    457466    sOutput, _ = oProcess.communicate();
     
    541550def sudoProcessPopen(*aPositionalArgs, **dKeywordArgs):
    542551    """
    543     sudo (or similar) + subprocess.Popen.
     552    sudo (or similar) + processPopenSafe.
    544553    """
    545554    _processFixPythonInterpreter(aPositionalArgs, dKeywordArgs);
    546555    _sudoFixArguments(aPositionalArgs, dKeywordArgs);
    547     return subprocess.Popen(*aPositionalArgs, **dKeywordArgs);
     556    return processPopenSafe(*aPositionalArgs, **dKeywordArgs);
    548557
    549558
Note: See TracChangeset for help on using the changeset viewer.

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