Skip to content

Commit

Permalink
fix PresentMon process spawning its own console in frozen executable
Browse files Browse the repository at this point in the history
  • Loading branch information
tappi287 committed Jul 4, 2021
1 parent d309100 commit fc17fa3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion rf2settings/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from queue import Queue, Empty
from typing import Union, Optional

from rf2settings.utils import subprocess_args


class RunProcess(threading.Thread):
result_timeout = 10
Expand Down Expand Up @@ -59,7 +61,7 @@ def _process_loop(args: Union[list, str], cwd: Optional[Path],
global_queue: Optional[Queue]):
""" Reads and writes process stdout to log until process ends """
try:
process = sp.Popen(args, stdout=sp.PIPE, stderr=sp.STDOUT, stdin=sp.PIPE, cwd=cwd)
process = sp.Popen(args, **subprocess_args(True, cwd=cwd))
except Exception as e:
logging.error('Error starting process: %s', e)
event.set()
Expand Down
5 changes: 3 additions & 2 deletions rf2settings/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def start_lnk_from_powershell(shortcut: Path):
#
# subprocess.check_output(['program_to_run', 'arg_1'],
# **subprocess_args(False))
def subprocess_args(include_stdout=True):
def subprocess_args(include_stdout=True, cwd=None):
# The following is true only on Windows.
if hasattr(sp, 'STARTUPINFO'):
# On Windows, subprocess calls will pop up a command window by default
Expand Down Expand Up @@ -240,7 +240,8 @@ def subprocess_args(include_stdout=True):
ret.update({'stdin': sp.PIPE,
'stderr': sp.PIPE,
'startupinfo': si,
'env': env})
'env': env,
'cwd': cwd})
return ret


Expand Down

0 comments on commit fc17fa3

Please sign in to comment.