mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 16:34:47 +01:00
Merge pull request #2217 from xonsh/term-fd
Fixes OSError Inappropriate ioctl for device
This commit is contained in:
commit
684dce97da
3 changed files with 23 additions and 7 deletions
14
news/term-fd.rst
Normal file
14
news/term-fd.rst
Normal file
|
@ -0,0 +1,14 @@
|
|||
**Added:** None
|
||||
|
||||
**Changed:** None
|
||||
|
||||
**Deprecated:** None
|
||||
|
||||
**Removed:** None
|
||||
|
||||
**Fixed:**
|
||||
|
||||
* Fixed issues like ``timeit ls`` causing OSError - "Inappropriate ioctl
|
||||
for device".
|
||||
|
||||
**Security:** None
|
|
@ -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,8 +127,7 @@ else:
|
|||
LIBC.sigprocmask(ctypes.c_int(signal.SIG_BLOCK),
|
||||
ctypes.byref(mask),
|
||||
ctypes.byref(omask))
|
||||
st = sys.stderr.fileno()
|
||||
LIBC.tcsetpgrp(ctypes.c_int(st), 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
|
||||
|
@ -136,7 +135,7 @@ else:
|
|||
def give_terminal_to(pgid):
|
||||
oldmask = signal.pthread_sigmask(signal.SIG_BLOCK,
|
||||
_block_when_giving)
|
||||
os.tcsetpgrp(sys.stderr.fileno(), pgid)
|
||||
os.tcsetpgrp(FD_STDERR, pgid)
|
||||
signal.pthread_sigmask(signal.SIG_SETMASK, oldmask)
|
||||
return True
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue