diff --git a/xonsh/jobs.py b/xonsh/jobs.py index 66e4e2e97..5cd849cda 100644 --- a/xonsh/jobs.py +++ b/xonsh/jobs.py @@ -10,7 +10,7 @@ import subprocess import collections from xonsh.lazyasd import LazyObject -from xonsh.platform import ON_DARWIN, ON_WINDOWS, ON_CYGWIN, LIBC +from xonsh.platform import FD_STDERR, ON_DARWIN, ON_WINDOWS, ON_CYGWIN, LIBC from xonsh.tools import unthreadable @@ -127,7 +127,7 @@ else: LIBC.sigprocmask(ctypes.c_int(signal.SIG_BLOCK), ctypes.byref(mask), ctypes.byref(omask)) - LIBC.tcsetpgrp(ctypes.c_int(2), ctypes.c_int(pgid)) + LIBC.tcsetpgrp(ctypes.c_int(FD_STDERR), ctypes.c_int(pgid)) LIBC.sigprocmask(ctypes.c_int(signal.SIG_SETMASK), ctypes.byref(omask), None) return True @@ -135,8 +135,7 @@ else: def give_terminal_to(pgid): oldmask = signal.pthread_sigmask(signal.SIG_BLOCK, _block_when_giving) - # cannot use sys.stderr.fileno(), will cause `timeit ls` etc fail - os.tcsetpgrp(2, pgid) + os.tcsetpgrp(FD_STDERR, pgid) signal.pthread_sigmask(signal.SIG_SETMASK, oldmask) return True diff --git a/xonsh/platform.py b/xonsh/platform.py index d78f168b2..66747e94c 100644 --- a/xonsh/platform.py +++ b/xonsh/platform.py @@ -14,6 +14,11 @@ import subprocess import importlib.util from xonsh.lazyasd import LazyBool, lazyobject, lazybool +# do not import any xonsh-modules here to avoid circular dependencies + +FD_STDIN = 0 +FD_STDOUT = 1 +FD_STDERR = 2 @lazyobject @@ -27,9 +32,6 @@ def distro(): return d -# do not import any xonsh-modules here to avoid circular dependencies - - # # OS # @@ -176,6 +178,7 @@ def pathbasename(p): """ return pathsplit(p)[-1] + # termios tc(get|set)attr indexes. IFLAG = 0 OFLAG = 1