X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?p=bin.git;a=blobdiff_plain;f=tiocnotty;h=715f8ee5a4905ee3804c3f290fff9d65954a4a9b;hp=1bf635e7e9d0dde24f8bfe7f4925a5cfb401f4b0;hb=e194128ac1ff9704514b133d6043ec2e99eb881d;hpb=daa61cc1db4ce5df90a0cfc18d22005d02d9f8c8 diff --git a/tiocnotty b/tiocnotty index 1bf635e..715f8ee 100755 --- a/tiocnotty +++ b/tiocnotty @@ -1,14 +1,13 @@ -#! /usr/bin/python +#! /usr/bin/python3 -import sys -import os import fcntl +import os +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