--- a/runtime/spawn_subprocess.py Wed Nov 22 11:24:16 2023 +0100
+++ b/runtime/spawn_subprocess.py Fri Nov 24 12:16:19 2023 +0100
@@ -14,17 +14,24 @@
- def __init__(self, args, stdin=None, stdout=None):
+ def __init__(self, args, stdin=None, stdout=None, stderr=None):
file_actions = posix_spawn.FileActions()
# child's stdout, child 2 parent pipe
+ c1pread, c1pwrite = os.pipe() + # attach child's stdout to writing en of c1p pipe + file_actions.add_dup2(c1pwrite, 1) + file_actions.add_close(c1pread) + # child's stderr, child 2 parent pipe c2pread, c2pwrite = os.pipe()
- # attach child's stdout to writing en of c2p pipe
- file_actions.add_dup2(c2pwrite, 1)
+ # attach child's stderr to writing en of c2p pipe + file_actions.add_dup2(c2pwrite, 2) file_actions.add_close(c2pread)
@@ -36,7 +43,10 @@
file_actions.add_close(p2cwrite)
self.pid = posix_spawn.posix_spawnp(args[0], args, file_actions=file_actions)
- self.stdout = os.fdopen(c2pread)
+ self.stdout = os.fdopen(c1pread) + self.stderr = os.fdopen(c2pread) self.stdin = os.fdopen(p2cwrite, 'w')
@@ -50,29 +60,44 @@
if self.stdin is not None:
if self.stdout is not None:
stdoutdata = self.stdout.read()
+ if self.stderr is not None: + stderrdata = self.stderr.read() if self.stdout is not None:
+ if self.stderr is not None: return (stdoutdata, stderrdata)
if self.stdin is not None:
if self.stdout is not None:
+ if self.stderr is not None: @@ -84,10 +109,15 @@
if self.stdin is not None:
if self.stdout is not None:
+ if self.stderr is not None: @@ -96,10 +126,15 @@
if self.stdin is not None:
if self.stdout is not None:
+ if self.stderr is not None: