def __init__(self, cmd, **kwargs):
start_new_session = kwargs.pop('start_new_session', True)
options = {
'stdout': subprocess.PIPE,
'stderr': subprocess.STDOUT,
'shell': True,
'bufsize': 1,
'close_fds': not ON_WINDOWS,
}
options.update(**kwargs)
if ON_WINDOWS:
# MSDN reference:
# http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863%28v=vs.85%29.aspx
create_new_process_group = 0x00000200
detached_process = 0x00000008
#options.update(creationflags=detached_process | create_new_process_group)
os.environ["COMSPEC"]= "powershell.exe"
elif start_new_session:
if sys.version_info < (3, 2):
options.update(preexec_fn=os.setsid)
else:
options.update(start_new_session=True)
super(PopenPatched, self).__init__(cmd, **options)
评论列表
文章目录