mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 16:34:47 +01:00
minor fixes
This commit is contained in:
parent
eba344f948
commit
91cc19566e
2 changed files with 22 additions and 21 deletions
|
@ -12,6 +12,7 @@ import collections
|
|||
|
||||
from xonsh.lazyasd import LazyObject
|
||||
from xonsh.platform import ON_DARWIN, ON_WINDOWS, ON_CYGWIN, LIBC
|
||||
from xonsh.tools import print_exception
|
||||
|
||||
|
||||
tasks = LazyObject(collections.deque, globals(), 'tasks')
|
||||
|
@ -160,13 +161,13 @@ else:
|
|||
ctypes.byref(omask), None)
|
||||
else:
|
||||
def give_terminal_to(pgid):
|
||||
oldmask = signal.pthread_sigmask(signal.SIG_BLOCK, _block_when_giving)
|
||||
oldmask = signal.pthread_sigmask(signal.SIG_BLOCK,
|
||||
_block_when_giving)
|
||||
try:
|
||||
os.tcsetpgrp(sys.stderr.fileno(), pgid)
|
||||
return True
|
||||
except Exception as e:
|
||||
print('tcsetpgrp error {}: {}'.format(e.__class__.__name__, e),
|
||||
file=sys.stderr)
|
||||
print_exception('error in tcsetpgrp:')
|
||||
return False
|
||||
finally:
|
||||
signal.pthread_sigmask(signal.SIG_SETMASK, oldmask)
|
||||
|
|
|
@ -1940,7 +1940,24 @@ class CommandPipeline:
|
|||
# Ending methods
|
||||
#
|
||||
|
||||
def end_internal(self, tee_output):
|
||||
def end(self, tee_output=True):
|
||||
"""
|
||||
End the pipeline, return the controlling terminal if needed.
|
||||
|
||||
Main things done in self._end().
|
||||
"""
|
||||
if self.ended:
|
||||
return
|
||||
self._end(tee_output=tee_output)
|
||||
if ON_WINDOWS:
|
||||
return
|
||||
pgid = os.getpgid(0)
|
||||
if self._term_pgid is None or pgid == self._term_pgid:
|
||||
return
|
||||
if give_terminal_to(pgid): # if gave term succeed
|
||||
self._term_pgid = pgid
|
||||
|
||||
def _end(self, tee_output):
|
||||
"""Waits for the command to complete and then runs any closing and
|
||||
cleanup procedures that need to be run.
|
||||
"""
|
||||
|
@ -1958,23 +1975,6 @@ class CommandPipeline:
|
|||
self.ended = True
|
||||
self._raise_subproc_error()
|
||||
|
||||
def end(self, tee_output=True):
|
||||
"""
|
||||
End the pipeline, return the controlling terminal if needed.
|
||||
|
||||
Main things done in end_internal().
|
||||
"""
|
||||
if self.ended:
|
||||
return
|
||||
self.end_internal(tee_output=tee_output)
|
||||
if ON_WINDOWS:
|
||||
return
|
||||
pgid = os.getpgid(0)
|
||||
if self._term_pgid is None or pgid == self._term_pgid:
|
||||
return
|
||||
if give_terminal_to(pgid): # if gave term succeed
|
||||
self._term_pgid = pgid
|
||||
|
||||
def _endtime(self):
|
||||
"""Sets the closing timestamp if it hasn't been already."""
|
||||
if self.endtime is None:
|
||||
|
|
Loading…
Add table
Reference in a new issue