2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-25 19:10:10 +00:00

On SLES operating systems, hit an error on the shutdown of

confluent when we call tcgetattr() with the following:
   termios.error: (25, 'Inappropriate ioctl for device')

Before calling tcgetattr, check that the file descriptor
is a tty.
This commit is contained in:
Victor Hu 2015-02-10 17:18:16 -05:00
parent 3756ee129a
commit 1f7a0e77d6

View File

@ -71,7 +71,10 @@ import confluent.client as client
conserversequence = '\x05c' # ctrl-e, c
oldtcattr = termios.tcgetattr(sys.stdin.fileno())
oldtcattr = None
fd = sys.stdin
if fd.isatty():
oldtcattr = termios.tcgetattr(fd.fileno())
netserver = None
laststate = {}
@ -469,7 +472,8 @@ def quitconfetty(code=0, fullexit=False, fixterm=True):
if fixterm or didconsole:
currfl = fcntl.fcntl(sys.stdin.fileno(), fcntl.F_GETFL)
fcntl.fcntl(sys.stdin.fileno(), fcntl.F_SETFL, currfl ^ os.O_NONBLOCK)
termios.tcsetattr(sys.stdin.fileno(), termios.TCSANOW, oldtcattr)
if oldtcattr is not None:
termios.tcsetattr(sys.stdin.fileno(), termios.TCSANOW, oldtcattr)
if fullexit:
sys.exit(code)
else:
@ -596,6 +600,7 @@ elif shellargs:
command = " ".join(shellargs)
do_command(command, netserver)
quitconfetty(fullexit=True, fixterm=False)
while inconsole or not doexit:
if inconsole:
rdylist, _, _ = select.select(