Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/general.py
diff options
context:
space:
mode:
authorAnton Hvornum <anton@hvornum.se>2022-05-08 18:36:32 +0200
committerGitHub <noreply@github.com>2022-05-08 18:36:32 +0200
commit80cee500e0ef0cf4de84b8b60b35c25f667e7a34 (patch)
treea9393a7f71b8d53429bbd0dacb4172fc01bc526d /archinstall/lib/general.py
parent5a1bd831324f4b6e997f5de4d5ef5c416354ad78 (diff)
SysCommand now sets working_directory on SysCommandWorker. Also made it so the parent process moves back to the original working directory, leaving the child process in the target working directory. (#1142)
Diffstat (limited to 'archinstall/lib/general.py')
-rw-r--r--archinstall/lib/general.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/archinstall/lib/general.py b/archinstall/lib/general.py
index 174acb8a..cf925de3 100644
--- a/archinstall/lib/general.py
+++ b/archinstall/lib/general.py
@@ -352,7 +352,6 @@ class SysCommandWorker:
# only way to get the traceback without loosing it.
self.pid, self.child_fd = pty.fork()
- os.chdir(old_dir)
# https://stackoverflow.com/questions/4022600/python-pty-fork-how-does-it-work
if not self.pid:
@@ -371,6 +370,9 @@ class SysCommandWorker:
log(f"{self.cmd[0]} does not exist.", level=logging.ERROR, fg="red")
self.exit_code = 1
return False
+ else:
+ # Only parent process moves back to the original working directory
+ os.chdir(old_dir)
self.started = time.time()
self.poll_object.register(self.child_fd, EPOLLIN | EPOLLHUP)
@@ -457,7 +459,14 @@ class SysCommand:
if self.session:
return self.session
- with SysCommandWorker(self.cmd, callbacks=self._callbacks, peak_output=self.peak_output, environment_vars=self.environment_vars, remove_vt100_escape_codes_from_lines=self.remove_vt100_escape_codes_from_lines) as session:
+ with SysCommandWorker(
+ self.cmd,
+ callbacks=self._callbacks,
+ peak_output=self.peak_output,
+ environment_vars=self.environment_vars,
+ remove_vt100_escape_codes_from_lines=self.remove_vt100_escape_codes_from_lines,
+ working_directory=self.working_directory) as session:
+
if not self.session:
self.session = session