Fixing SysCommandWorker()

This commit is contained in:
Anton Hvornum 2022-02-10 18:48:26 +01:00
parent 4818fd9da7
commit 907430b1ac
1 changed files with 7 additions and 1 deletions

View File

@ -345,6 +345,12 @@ class SysCommandWorker:
except ChildProcessError:
self.exit_code = 1
def is_child(self):
return self.pid == 0
def is_parent(self):
return self.pid > 0
def execute(self) -> bool:
import pty
@ -364,7 +370,7 @@ class SysCommandWorker:
os.chdir(old_dir)
# https://stackoverflow.com/questions/4022600/python-pty-fork-how-does-it-work
if not self.pid:
if self.is_child():
try:
try:
with open(f"{storage['LOG_PATH']}/cmd_history.txt", "a") as cmd_log: