mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
cool
This commit is contained in:
parent
56a744d01d
commit
6e9721f1df
2 changed files with 13 additions and 2 deletions
|
@ -370,7 +370,7 @@ def no_pg_xonsh_preexec_fn():
|
|||
"""Default subprocess preexec function for when there is no existing
|
||||
pipeline group.
|
||||
"""
|
||||
#os.setpgrp()
|
||||
os.setpgrp()
|
||||
signal.signal(signal.SIGTSTP, default_signal_pauser)
|
||||
|
||||
|
||||
|
@ -601,7 +601,7 @@ class SubprocSpec:
|
|||
|
||||
def xonsh_preexec_fn():
|
||||
"""Preexec function bound to a pipeline group."""
|
||||
#os.setpgid(0, pipeline_group)
|
||||
os.setpgid(0, pipeline_group)
|
||||
signal.signal(signal.SIGTSTP, default_signal_pauser)
|
||||
|
||||
kwargs["preexec_fn"] = xonsh_preexec_fn
|
||||
|
|
|
@ -209,6 +209,8 @@ def populate_fd_queue(reader, fd, queue):
|
|||
If this ends or fails, it flags the calling reader object as closed.
|
||||
"""
|
||||
while True:
|
||||
if reader.closed:
|
||||
break
|
||||
try:
|
||||
c = os.read(fd, 1024)
|
||||
except OSError:
|
||||
|
@ -237,6 +239,7 @@ class NonBlockingFDReader(QueueReader):
|
|||
The queue reading timeout.
|
||||
"""
|
||||
super().__init__(fd, timeout=timeout)
|
||||
self.closed = False
|
||||
# start reading from stream
|
||||
self.thread = threading.Thread(
|
||||
target=populate_fd_queue, args=(self, self.fd, self.queue)
|
||||
|
@ -254,6 +257,8 @@ def populate_buffer(reader, fd, buffer, chunksize):
|
|||
"""
|
||||
offset = 0
|
||||
while True:
|
||||
if reader.closed:
|
||||
break
|
||||
try:
|
||||
buf = os.pread(fd, chunksize, offset)
|
||||
except OSError:
|
||||
|
@ -641,6 +646,11 @@ class PopenThread(threading.Thread):
|
|||
# loop over reads while process is running.
|
||||
i = j = cnt = 1
|
||||
while proc.poll() is None:
|
||||
_, wcode = os.waitpid(self.pid, os.WNOHANG)
|
||||
if os.WIFSTOPPED(wcode):
|
||||
if procout is not None:
|
||||
os.close(procout.fd)
|
||||
procout.closed = True
|
||||
# this is here for CPU performance reasons.
|
||||
if i + j == 0:
|
||||
cnt = min(cnt + 1, 1000)
|
||||
|
@ -1875,6 +1885,7 @@ class CommandPipeline:
|
|||
pipeline_group = proc.pid
|
||||
if update_fg_process_group(pipeline_group, background):
|
||||
self.term_pgid = pipeline_group
|
||||
print("PROC", pipeline_group, proc.pid, self.term_pgid)
|
||||
self.procs.append(proc)
|
||||
self.proc = self.procs[-1]
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue