Only wait for elevated process to end when arg is set (#7488)
* Only wait for elevated script to exit when required * Add missing space and only create lock file if wait enabled * Update ChangeLog * Fixed case for wait_for_exit
This commit is contained in:
parent
1c71b4f0f3
commit
df1ab6ef09
3 changed files with 18 additions and 11 deletions
|
|
@ -17,6 +17,7 @@ Enhancements:
|
||||||
- #7474 FreeBSD GitHub runner with `vmactions/freebsd-vm@v1`
|
- #7474 FreeBSD GitHub runner with `vmactions/freebsd-vm@v1`
|
||||||
- #7479 Add `BUILD.md` to get people started
|
- #7479 Add `BUILD.md` to get people started
|
||||||
- #7485 Use `.venv` dir for as Python venv and cache
|
- #7485 Use `.venv` dir for as Python venv and cache
|
||||||
|
- #7488 Only wait for elevated process to end when arg is set
|
||||||
|
|
||||||
# 1.15.1
|
# 1.15.1
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -222,7 +222,9 @@ class Dependencies:
|
||||||
|
|
||||||
if not self.args.skip_elevated:
|
if not self.args.skip_elevated:
|
||||||
if not windows.is_admin():
|
if not windows.is_admin():
|
||||||
windows.run_elevated(__file__, "--only-elevated --skip-python")
|
windows.run_elevated(
|
||||||
|
__file__, "--only-elevated --skip-python", wait_for_exit=True
|
||||||
|
)
|
||||||
elif self.args.only_elevated:
|
elif self.args.only_elevated:
|
||||||
# The choco command should run from the elevated command.
|
# The choco command should run from the elevated command.
|
||||||
choco = windows.WindowsChoco()
|
choco = windows.WindowsChoco()
|
||||||
|
|
|
||||||
|
|
@ -30,12 +30,15 @@ WIX_FILE = f"{BUILD_DIR}/installer/Synergy.sln"
|
||||||
MSI_FILE = f"{BUILD_DIR}/installer/bin/Release/Synergy.msi"
|
MSI_FILE = f"{BUILD_DIR}/installer/bin/Release/Synergy.msi"
|
||||||
|
|
||||||
|
|
||||||
def run_elevated(script, args=None, use_sys_argv=True):
|
def run_elevated(script, args=None, use_sys_argv=True, wait_for_exit=False):
|
||||||
if not args and use_sys_argv:
|
if not args and use_sys_argv:
|
||||||
args = " ".join(sys.argv[1:])
|
args = " ".join(sys.argv[1:])
|
||||||
|
|
||||||
env.persist_lock_file(LOCK_FILE)
|
if wait_for_exit:
|
||||||
command = f"{script} --pause-on-exit --lock-file {LOCK_FILE} {args}"
|
args += f" --lock-file {LOCK_FILE}"
|
||||||
|
env.persist_lock_file(LOCK_FILE)
|
||||||
|
|
||||||
|
command = f"{script} {args} --pause-on-exit"
|
||||||
print(f"Running script with elevated privileges: {command}")
|
print(f"Running script with elevated privileges: {command}")
|
||||||
|
|
||||||
WINDOW_HANDLE = None
|
WINDOW_HANDLE = None
|
||||||
|
|
@ -60,14 +63,15 @@ def run_elevated(script, args=None, use_sys_argv=True):
|
||||||
|
|
||||||
print("Script is running with elevated privileges")
|
print("Script is running with elevated privileges")
|
||||||
|
|
||||||
with open(LOCK_FILE, "r") as f:
|
if wait_for_exit:
|
||||||
pid = f.read()
|
with open(LOCK_FILE, "r") as f:
|
||||||
|
pid = f.read()
|
||||||
|
|
||||||
print(f"Waiting for elevated process to exit: {pid}")
|
print(f"Waiting for elevated process to exit: {pid}")
|
||||||
while os.path.exists(LOCK_FILE):
|
while os.path.exists(LOCK_FILE):
|
||||||
# Intentionally wait forever, since this code should not run where a developer
|
# Intentionally wait forever, since this code should not run where a developer
|
||||||
# has no control, such as in a CI environment.
|
# has no control, such as in a CI environment.
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def is_admin():
|
def is_admin():
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue