X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?p=bin.git;a=blobdiff_plain;f=tiocnotty;h=715f8ee5a4905ee3804c3f290fff9d65954a4a9b;hp=694c62ddfe45ef79993a305610021e9dbc3484d1;hb=c9be4f7b6e5d734a24a93d2c8ea9dd19f62eea84;hpb=b29b50dc79ed452de8407f0466ac85c9a04b5a8f diff --git a/tiocnotty b/tiocnotty index 694c62d..715f8ee 100755 --- a/tiocnotty +++ b/tiocnotty @@ -1,4 +1,4 @@ -#! /usr/bin/python +#! /usr/bin/python3 import fcntl import os @@ -6,9 +6,8 @@ import sys import termios try: - tty = open('/dev/tty') - fcntl.ioctl(tty, termios.TIOCNOTTY) - tty.close() + with open('/dev/tty') as tty: + fcntl.ioctl(tty, termios.TIOCNOTTY) except IOError: pass