Made sure SysCommandWorker() exits after os.execve() is done, that way we'll never continue on split code paths by mistake
This commit is contained in:
parent
2ca86281ac
commit
3e2c816b51
|
|
@ -323,7 +323,7 @@ class SysCommandWorker:
|
|||
def poll(self) -> None:
|
||||
self.make_sure_we_are_executing()
|
||||
|
||||
if self.child_fd:
|
||||
if self.is_parent():
|
||||
got_output = False
|
||||
for fileno, event in self.poll_object.poll(0.1):
|
||||
try:
|
||||
|
|
@ -366,6 +366,7 @@ class SysCommandWorker:
|
|||
# otherwise it will bleed into the child: https://docs.python.org/3/library/os.html#os.execvpe
|
||||
sys.stdout.flush()
|
||||
|
||||
self.started = time.time()
|
||||
self.pid, self.child_fd = pty.fork()
|
||||
os.chdir(old_dir)
|
||||
|
||||
|
|
@ -379,15 +380,24 @@ class SysCommandWorker:
|
|||
pass
|
||||
|
||||
os.execve(self.cmd[0], list(self.cmd), {**os.environ, **self.environment_vars})
|
||||
if storage['arguments'].get('debug'):
|
||||
log(f"Executing: {self.cmd}", level=logging.DEBUG)
|
||||
|
||||
except FileNotFoundError:
|
||||
log(f"{self.cmd[0]} does not exist.", level=logging.ERROR, fg="red")
|
||||
self.exit_code = 1
|
||||
return False
|
||||
with open(f"{storage['LOG_PATH']}/cmd_output.txt", "a") as peak_output_log:
|
||||
peak_output_log(f"[ERROR] {self.cmd[0]} does not exist.")
|
||||
|
||||
exit(1)
|
||||
|
||||
except OSError as error:
|
||||
with open(f"{storage['LOG_PATH']}/cmd_output.txt", "a") as peak_output_log:
|
||||
peak_output_log.write(f"{self.cmd[0]} ran into an error: {error}")
|
||||
|
||||
exit(1)
|
||||
|
||||
exit(0)
|
||||
else:
|
||||
if storage['arguments'].get('debug'):
|
||||
log(f"Executing: {self.cmd}", level=logging.DEBUG)
|
||||
|
||||
self.started = time.time()
|
||||
self.poll_object.register(self.child_fd, EPOLLIN | EPOLLHUP)
|
||||
|
||||
return True
|
||||
|
|
|
|||
Loading…
Reference in New Issue