defined some constants

This commit is contained in:
Hugo Wang 2017-02-19 10:08:28 +08:00
parent 5d3d033cb2
commit db9a6d576f
2 changed files with 9 additions and 7 deletions

View file

@ -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

View file

@ -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